无法解析相对于项目的黄瓜支持文件路径



我正在使用Cucumber进行一些e2e测试,但我不能要求具有项目相对路径的支持文件:

node_modules
cucumber
├── features
├── step_definitions

我使用此命令运行测试

./node_modules/.bin/cucumber-js cucumber/features --require cucumber/step_definitions

Cucumber 能够以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);

一切正常。谁能告诉我我在这里错过了什么?

谢谢

我终于解决了我的问题:问题出在 cucumber-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"
}
}

最新更新