cucumber-js icon indicating copy to clipboard operation
cucumber-js copied to clipboard

'@cucumber/cucumber/api' module is not found when running in CI

Open uzeyirqa opened this issue 3 years ago • 0 comments

Getting Error: Cannot find module '@cucumber/cucumber/api' in Jenkins.

call stack:

Error: Cannot find module '@cucumber/cucumber/api'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.<anonymous> (/home/ciuser/jenkins/workspace/NAW-PW-E2E/Alpha/tests/pw-e2e/index.js:6:44)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)

using Node version 16.16.0 @Cucumber/cucumber: 8.2.0 Running the tests on CentOs 7 machine with 8 core CPU, using 4 workers.

I use cucumber coupled with playwright. I use loadConfiguration and runCucumber functions from @cucumber/cucumber/api to start cucumber programmatically. Since the project is used as an NPM package throughout our organization.

the code:

const { loadConfiguration, runCucumber } = require('@cucumber/cucumber/api');

async function runTests() {
  // things we need to specify about the environment
  const environment = { cwd: process.cwd() };
  // load configuration from a particular file, and override a specific option
  const { runConfiguration } = await loadConfiguration({ file: configFilePath, provided: { failFast: false, backtrace: true,tags:config.tags, paths:getFeatures(),require: [path.resolve(__dirname, 'support'), getStepsPath()], format: [`json:${path.resolve(__dirname, 'cucumber-report.json')}`]} }, environment);
  // run cucumber, using the support code we loaded already
  const { success } = await runCucumber(runConfiguration, environment);
  return success;
}
runTests();

This is a flaky issue, It happens only during run time on CI environment, and is not constant but it leads to build failure.

uzeyirqa avatar Aug 08 '22 07:08 uzeyirqa