【发布时间】:2020-02-01 21:00:45
【问题描述】:
我可能混淆了概念,但 I'd read that it's possible to get TestCafe to recognize variables 的形式是 process.env.MY_COOL_VARIABLE。同样对于我的 Vue.js 前端(使用 Vue-CLI,which uses dotenv under the hood 构建),我发现我可以在.env.test 中为测试值创建一个文件,如下所示:
VUE_APP_MY_COOL_VARIABLE
然后我会像这样在我的测试代码中访问它:
test('my fixture', async (t) => {
...
await t
.click(mySelector.find('.div').withText(process.env.VUE_APP_MY_COOL_VARIABLE));
...
}
但是,我收到以下错误:
"text" argument is expected to be a string or a regular expression, but it was undefined.
似乎我的环境变量没有被拾取。我像这样构建我的代码:vue-cli-service build --mode test。
【问题讨论】:
标签: automated-tests e2e-testing vue-cli testcafe dotenv