![](/img/trans.png)
[英]How to fix nodejs throw err; ^ Error: ENOENT: no such file or directory, open
[英]How to fix "Error: ENOENT: no such file or directory - cypress plugins in jenkins"
Cypress 测试 --> 我在 plugins/index.js 中添加了以下代码,本地测试运行良好,但在 jenkins 上运行时出现错误
function getConfigurationByFile(file) {
const pathToConfigFile = path.resolve(
'..',
'automation/cypress/configFiles',
`${file}.json`
);
return fs.readJson(pathToConfigFile);
}
module.exports = (on, config) => {
const file = config.env.fileConfig || 'qat';
return getConfigurationByFile(file);
};
jenkins 中的错误 -->
plugins文件导出的function报错。 我们调用了/var/lib/jenkins/jenkins-agent/workspace/ui-automation/cypress/plugins/index.js
导出的 function ,但它抛出了一个错误。
错误:ENOENT:没有这样的文件或目录,打开“/var/lib/jenkins/jenkins-agent/workspace/automation/cypress/configFiles/qat.json”
我能够解决这个问题。 我的代码中的工作区路径不正确。
jenkins 工作区:工作区/ui-automation/cypress/
本地工作空间:工作空间/自动化/柏树
更新代码:
const pathToConfigFile = path.resolve(
'..',
'ui-automation/cypress/configFiles',
`${file}.json`
);
return fs.readJson(pathToConfigFile);
}
module.exports = (on, config) => {
const file = config.env.fileConfig || 'qat';
return getConfigurationByFile(file);
};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.