【发布时间】:2020-06-01 17:28:24
【问题描述】:
我正在尝试在Cypress.io 中设置和配置一个新的env 变量。在文件cypress/plugins/index.js 中,我导入了另一个文件,如下所示:
const { getBranch } = require('path/to/file/goes/here/getBranch');
然后,我尝试像这样设置新的env 变量:
// cypress/plugins/index.js
module.exports = (on, config) => {
terminalReport.installPlugin(on);
const configuration = config;
configuration.env.injectMainBranchId = getBranch('develop');
// more code below...
但是,这不起作用。但是,如果我硬编码它确实有效的值:
configuration.env.injectMainBranchId = 'develop';
这是getBranch模块的虚拟内容:
const getBranch = branch => {
return branch;
};
module.export = { getBranch };
我做错了什么?
【问题讨论】:
-
module.exports = { getBranch };中的错字 -
乐于助人:)
标签: javascript import module environment-variables cypress