简体   繁体   English

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

[英]unable to resolve cucumber support files path relative to project

I'm using Cucumber to do some e2e tests but I can't require support files with relative path to the project: 我正在使用Cucumber进行一些e2e测试,但是我不能要求具有项目相对路径的支持文件:

node_modules
cucumber
├── features
├── step_definitions

I run test using this command 我使用此命令运行测试

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

Cucumber is able to list files in cucumber/step_definitions but can't require them: Error: Cannot find module 'cucumber/step_definitions/stepFile.js' 黄瓜能够列出cucumber/step_definitions中的文件,但是不需要它们: Error: Cannot find module 'cucumber/step_definitions/stepFile.js'

When I changed line 163 of /node_modules/cucumber/lib/cli/index.js: 当我更改/node_modules/cucumber/lib/cli/index.js的第163行时:

return require(codePath);

by: 通过:

return require(process.cwd()+'/'+codePath);

everything works correctly. 一切正常。 Can anyone tell me what I'm missing here ? 谁能告诉我我在这里想念的吗?

Thanks 谢谢

I finally resolved my issue: The problem is with the version of the glob dependency in cucumber-js. 我终于解决了我的问题:问题出在黄瓜js中的glob依赖版本。 By changing its version to 7.1.2 in package-lock, the paths are resolved as expected: 通过在包锁定中将其版本更改为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"
  }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM