When I try to run Cucumber tests with Cypress, I get error saying:
Your
configFilethrew an error from:cypress.config.jsWe stopped running your tests because your config file crashed.
Tried upgrading and downgrading Node.
Also tried with different cypress-cucumber-preprocessor but that didn't help.
My index.js file is:
const createEsbuildPlugin =
    require('@badeball/cypress-cucumber-preprocessor/esbuild').createEsbuildPlugin
const createBundler = require('@bahmutov/cypress-esbuild-preprocessor')
const nodePolyfills =
    require('@esbuild-plugins/node-modules-polyfill').NodeModulesPolyfillPlugin
const addCucumberPreprocessorPlugin =
    require('@badeball/cypress-cucumber-preprocessor').addCucumberPreprocessorPlugin
module.exports = async (on, config) => {
    await addCucumberPreprocessorPlugin(on, config) // to allow json to be produced
    // To use esBuild for the bundler when preprocessing
    on(
        'file:preprocessor',
        createBundler({
            plugins: [nodePolyfills(), createEsbuildPlugin(config)],
        })
    )
    return config
}
And config.js file snippet:
const { defineConfig } = require('cypress')
const selectTestsWithGrep = require('cypress-select-tests/grep')
const allureWriter = require("@shelex/cypress-allure-plugin/writer");
module.exports = defineConfig({
  env: {
    baseurl: 'https://google.com',
    username: 'admin',
    password: 'admin',
  },
  video: false,
  screenshotsFolder: 'screenshots',
  chromeWebSecurity: false,
  defaultCommandTimeout: 45000,
  pageLoadTimeout: 90000,
  screenshotOnRunFailure: true,
  viewportWidth: 1400,
  viewportHeight: 900,
  e2e: {
    specPattern: ["**/*.feature", "cypress/e2e/**/*.cy.{js,jsx,ts,tsx}"],
    supportFile: false,
    // excludeSpecPattern: "*.js",
    setupNodeEvents(on, config) {
      //require('cypress-mochawesome-reporter/plugin')(on);
      on('file:preprocessor', selectTestsWithGrep(config));
      allureWriter(on, config);
      return config;
    }
  }
})
