【发布时间】:2021-03-10 11:48:49
【问题描述】:
我有一个像这样的sample.js 文件:
赛普拉斯/fixtures/sample.js
module.exports = {
username: Cypress.env('username'),
password: Cypress.env('password')
}
和 Cypress.json 就像:
{
"baseUrl": "http://localhost:3000",
"video": false,
"viewportWidth": 375,
"viewportHeight": 812,
"defaultCommandTimeout": 10000,
"retries": {
"runMode": 2,
"openMode": 0
},
"env": {
"username": "******",
"password": "******"
}
}
但它不起作用并返回:
赛普拉斯没有定义!
【问题讨论】:
-
跑步者将赛普拉斯全局注入测试,但不注入固定装置。我不记得看到将其导入 sample.js 的方法(尽管可能使用模块 api)。你是如何使用 sample.js 的?是否需要在那里动态设置属性?
-
@MarionMorrison 不一定,我删除了fixture文件并在命令中使用了envs。
标签: environment-variables next.js cypress fixtures