【发布时间】:2019-07-08 07:18:12
【问题描述】:
是否可以在 cypress.io 中使用机会插件?
我通过 npm 将插件安装到 node_modules\chance 并编辑了 /plugins/index.js 文件,但仍然从 cypress 收到错误 - 无法启动,插件文件丢失或无效。
如果使用这个插件是不可能的 - 你建议如何编写基于注册新用户的测试?我计划利用机会生成“随机:电子邮件和密码。
// ***********************************************************
// This example plugins/index.js can be used to load plugins
//
// You can change the location of this file or turn off loading
// the plugins file with the 'pluginsFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/plugins-guide
// ***********************************************************
// This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing)
module.exports = on => {
on("task", {
chance: require("chance"),
});
};
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
}
【问题讨论】:
-
目前没有意义,
on期望第二个参数是 回调。阅读docs.cypress.io/guides/tooling/plugins-guide.html -
那么我应该如何计划有关创建新帐户的测试有什么建议吗?唯一的方法是使用自己的后端副本?
-
这是一个完全独立的问题,我只是说你不能使用机会 like that 因为这不是你在 Cypress 中使用插件的方式(我也不认为这是一个赛普拉斯插件)。但我也绝对不建议在真实数据库中生成随机用户作为测试策略。
标签: javascript cypress