0
votes

I'm using Cucumber to do some e2e tests but I can't require support files with relative path to the project:

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'

When I changed line 163 of /node_modules/cucumber/lib/cli/index.js:

return require(codePath);

by:

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

everything works correctly. Can anyone tell me what I'm missing here ?

Thanks

1

1 Answers

0
votes

I finally resolved my issue: The problem is with the version of the glob dependency in cucumber-js. By changing its version to 7.1.2 in package-lock, the paths are resolved as expected:

"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"
  }
}