badeball / cypress-parallel

Cypress parallelization in any CI environment, without depending on external services
MIT License
17 stars 6 forks source link

Test files not being found #8

Closed ParsonsProjects closed 1 month ago

ParsonsProjects commented 1 month ago

Current behavior

Fails to run after running npx cypress-parallel --node 1:5

Unable to find knapsack.json, continuing without it...
node:events:492
      throw er; // Unhandled 'error' event
      ^

Error: spawn npx ENOENT
    at ChildProcess._handle.onexit (node:internal/child_process:286:19)
    at onErrorNT (node:internal/child_process:484:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
Emitted 'error' event on ChildProcess instance at:
    at ChildProcess._handle.onexit (node:internal/child_process:292:12)
    at onErrorNT (node:internal/child_process:484:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'spawn npx',
  path: 'npx',
  spawnargs: [
    'cypress',
    'run',
    '--config',
    'fixturesFolder=tests/cypress/e2e/fixtures',
    '--reporter',
    'cypress-multi-reporters',
    '--reporter-options',
    '{"reporterEnabled":"spec, @badeball/cypress-parallel/knapsack-reporter","badeballCypressParallelKnapsackReporterReporterOptions":{"output":"knapsack.json"}}',
    '--spec',
    ''
  ]
}

Node.js v20.10.0

Desired behavior

Runs tests in parallel.

Notes

It looks like this package is having issues picking up the cypress configuration which results in no test files being picked up and passed into the command line, I see that this package also uses @badeball/cypress-configuration the same as @badeball/cypress-cucumber-preprocessor I currently have @badeball/cypress-cucumber-preprocessor installed and working. See cypress config below:

import { defineConfig } from 'cypress';
import createBundler from '@bahmutov/cypress-esbuild-preprocessor'
import { addCucumberPreprocessorPlugin } from "@badeball/cypress-cucumber-preprocessor";
import { createEsbuildPlugin } from "@badeball/cypress-cucumber-preprocessor/esbuild";

async function setupNodeEvents(on, config) {
  // This is required for the preprocessor to be able to generate JSON reports after each run, and more,
  await addCucumberPreprocessorPlugin(on, config);

  on(
    "file:preprocessor",
    createBundler({
      plugins: [createEsbuildPlugin(config)],
    })
  );

  // code coverage setup
  // eslint-disable-next-line import/no-extraneous-dependencies, global-require, @typescript-eslint/no-var-requires
  // require('@cypress/code-coverage/task')(on, config);

  // Make sure to return the config object as it might have been modified by the plugin.
  return config;
}

module.exports = defineConfig({
  // setupNodeEvents can be defined in either
  // the e2e or component configuration
  projectId: 'qqghr1',
  viewportWidth: 1536,
  viewportHeight: 960,
  defaultCommandTimeout: 15000,
  pageLoadTimeout: 20000,
  numTestsKeptInMemory: 20,
  retries: {
    runMode: 2,
    openMode: 0,
  },
  component: {},
  e2e: {
    baseUrl: 'http://localhost:9000/',
    fixturesFolder: 'tests/cypress/e2e/fixtures',
    screenshotsFolder: 'tests/cypress/e2e/screenshots',
    videosFolder: 'tests/cypress/e2e/videos',
    supportFile: 'tests/cypress/e2e/support/index.js',
    specPattern: 'tests/cypress/e2e/features/**/*.feature',
    video: true,
    setupNodeEvents,
  },
  videoUploadOnPasses: false,
  // https://github.com/cypress-io/cypress/issues/26284
  morgan: false,
  experimentalInteractiveRunEvents: true,
  experimentalMemoryManagement: true,
});

Versions

badeball commented 1 month ago

It looks like this package is having issues picking up the cypress configuration which results in no test files being picked up [..]

To me it looks like it fails to execute npx, which normally exists in your PATH assuming you're using npm.

In any case, I recommend using a different library to parallelize your tests. This repository will soon be archived.