我正在使用Cucumber进行一些e2e测试,但是我不需要具有项目相对路径的支持文件:
node_modules
cucumber
├── features
├── step_definitions
我使用此命令进行测试
./node_modules/.bin/cucumber-js cucumber/features --require cucumber/step_definitions
黄瓜能够列出cucumber/step_definitions
中的文件,但不能要求它们:Error: Cannot find module 'cucumber/step_definitions/stepFile.js'
当我更改/node_modules/cucumber/lib/cli/index.js的第163行时:
return require(codePath);
作者:
return require(process.cwd()+'/'+codePath);
一切正常。谁能告诉我我在这里想念的东西吗?
谢谢
答案 0 :(得分:0)
我终于解决了我的问题:问题出在黄瓜js中的glob依赖版本。通过在包锁定中将其版本更改为7.1.2,可以按预期解析路径:
"glob": {
"version": "7.1.2",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz",
"integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==",
"dev": true,
"optional": true,
"requires": {
"fs.realpath": "1.0.0",
"inflight": "1.0.6",
"inherits": "2.0.3",
"minimatch": "3.0.4",
"once": "1.4.0",
"path-is-absolute": "1.0.1"
}
}