codeceptjs / CodeceptJS

Supercharged End 2 End Testing Framework for NodeJS

Home Page:http://codecept.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Could not load helper JSONResponse from module './helper/JSONResponse': Cannot find module 'joi'

surya-purohit opened this issue · comments

What are you trying to achieve?

I am trying to run my integration tests with the command dotenv -- codeceptjs run --features --steps

What do you get instead?

I am getting error

Require stack:
- myproject/node_modules/codeceptjs/lib/helper/JSONResponse.js
- myproject/node_modules/codeceptjs/lib/container.js
- myproject/node_modules/codeceptjs/lib/codecept.js
- myproject/node_modules/codeceptjs/bin/codecept.js
Error: Cannot find module 'joi'
Require stack:
- myproject/node_modules/codeceptjs/lib/helper/JSONResponse.js
- myproject/node_modules/codeceptjs/lib/container.js
- myproject/node_modules/codeceptjs/lib/codecept.js
- myproject/node_modules/codeceptjs/bin/codecept.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1144:15)
    at Module._load (node:internal/modules/cjs/loader:985:27)
    at Module.require (node:internal/modules/cjs/loader:1235:19)
    at require (node:internal/modules/helpers:176:18)
    at Object.<anonymous> (myproject/node_modules/codeceptjs/lib/helper/JSONResponse.js:10:13)
    at Module._compile (node:internal/modules/cjs/loader:1376:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
    at Module.load (node:internal/modules/cjs/loader:1207:32)
    at Module._load (node:internal/modules/cjs/loader:1023:12)
    at Module.require (node:internal/modules/cjs/loader:1235:19)

Error:
    at createHelpers (myproject/node_modules/codeceptjs/lib/container.js:194:13)
    at Container.create (myproject/node_modules/codeceptjs/lib/container.js:44:25)
    at Codecept.init (myproject/node_modules/codeceptjs/lib/codecept.js:57:15)
    at module.exports (myproject/node_modules/codeceptjs/lib/command/run.js:28:14)
    at Command.<anonymous> (myproject/node_modules/codeceptjs/bin/codecept.js:9:11)
    at Command.listener [as _actionHandler] (myproject/node_modules/commander/lib/command.js:494:17)
    at myproject/node_modules/commander/lib/command.js:1296:65
    at Command._chainOrCall (myproject/node_modules/commander/lib/command.js:1193:12)
    at Command._parseCommand (myproject/node_modules/commander/lib/command.js:1296:27)
    at myproject/node_modules/commander/lib/command.js:1082:27
npm ERR! Lifecycle script `test:integration` failed with error:
npm ERR! Error: command failed

Provide console output if related. Use --verbose mode for more details.

# paste output here

Provide test source code if related

// paste test

Details

  • CodeceptJS version: 3.5.13
  • NodeJS Version: v20.11.0
  • Operating System: MacOS 14.3.1 (23D60) Chip: Apple M1
  • puppeteer || webdriverio || testcafe version (if related)
  • Configuration file:
const cp = require('child_process');

const CIMode = process.env.CI === 'true';

if (CIMode) {
  console.log('Running in CI Mode.', process.env.IT_TAG);
}

const clientPlaywrightVersion = cp.execSync('npx playwright --version').toString().trim().split(' ')[1];
const chromiumArgs = ['--host-resolver-rules=MAP local.some.io 127.0.0.1, MAP local.some.io ::1'];

exports.config = {
  grep: process.env.IT_TAG,
  output: './tests/integration/output',
  helpers: {
    Playwright: {
      url: process.env.PORTAL_URL,
      show: !CIMode,
      video: false, // Change this to true when needed for debugging
      browser: 'chromium',
      windowSize: '1440x700',
      timeout: 60000,
      emulate: {
        permissions: ['clipboard-read', 'clipboard-write', 'accessibility-events'],
      },
      chromium: {
        ...(CIMode ? { args: ['--disable-gpu', ...chromiumArgs] } : { args: chromiumArgs }),
        ...(process.env.BROWSERSTACK_USERNAME
          ? {
              browserWSEndpoint: {
                wsEndpoint: `wss://cdp.browserstack.com/playwright?caps=${encodeURIComponent(
                  JSON.stringify({
                    browser: 'chrome',
                    os: 'Windows',
                    os_version: '11',
                    name: 'integration tests',
                    build: 'tests on BrowserStack',
                    'browserstack.username': process.env.BROWSERSTACK_USERNAME,
                    'browserstack.accessKey': process.env.BROWSERSTACK_ACCESS_KEY,
                    'client.playwrightVersion': clientPlaywrightVersion,
                  }),
                )}`,
              },
            }
          : {}),
      },
      ignoreHTTPSErrors: true,
    },
    JSONResponse: {
      requestHelper: 'Playwright',
    },
    ChaiWrapper: {
      require: 'codeceptjs-chai',
    },
    FileSystem: {},
    PixelmatchHelper: {
      require: 'codeceptjs-pixelmatchhelper',
      dirExpected: `./tests/integration/screenshots/base/${CIMode ? 'ci' : 'local'}`,
      dirDiff: './tests/integration/screenshots/diff/',
      tolerance: 10,
      threshold: 0.05,
    },
  },
  gherkin: {
    features: './tests/integration/features/**/*.feature',
    steps: ['./tests/integration/step_definitions/steps.js'],
  },
  plugins: {
    screenshotOnFail: { enabled: true },
    pauseOnFail: { enabled: !CIMode },
    retryFailedStep: { enabled: true, factor: 3 },
    retryTo: { enabled: true },
    autoLogin: {
      enabled: true,
      inject: 'login',
      saveToFile: true,
    },
  },
  mocha: {
    bail: process.env.Some_URL.includes('ate'),
    reporterOptions: {
      'codeceptjs-cli-reporter': {
        stdout: '-',
        options: {
          steps: true,
        },
      },
      'mocha-junit-reporter': {
        stdout: './output/console.log',
        options: { mochaFile: 'reports/codecept.xml', attachments: true },
      },
    },
  },
  name: 'SOMETHING',
};