Setting up cypress-cucumber-preprocessor with Cypress v13.4.0

358 views Asked by At

I'm getting an error with the latest configuration of cypress-cucumber-preprocessor

Your configFile threw an error from: ...\cypress.config.ts
The error was thrown while executing your e2e.setupNodeEvents() function:
TypeError: (0 , cypress_esbuild_preprocessor_1.default) is not a function...

Versions:

"@badeball/cypress-cucumber-preprocessor": "^18.0.6",
"@bahmutov/cypress-esbuild-preprocessor": "^2.2.0",
"cypress": "^13.4.0",

This is the config I use, taken from cypress-cucumber-preprocessor/examples/esbuild-cjs /cypress.config.js

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

export default defineConfig({
  e2e: {
    specPattern: "**/*.feature",
    async setupNodeEvents(on: Cypress.PluginEvents, config: Cypress.PluginConfigOptions): Promise<Cypress.PluginConfigOptions> {
      await addCucumberPreprocessorPlugin(on, config);
      on("file:preprocessor", createBundler({plugins: [createEsbuildPlugin(config)]}));
      return config;
    },
  },
})

The config is almost identical to the last version I used, with these versions:

"@badeball/cypress-cucumber-preprocessor": "^15.0.0",
"@bahmutov/cypress-esbuild-preprocessor": "^2.1.5",
"cypress": "^12.1.0",

except at that time createEsbuildPlugin was the default export.

I tried the latest as default and named imports, but both give the error.

Also tried the tsconfig.json addition recommended (which wasn't used in the older project)

  "compilerOptions": {
    "module": "nodenext", 
  }
0

There are 0 answers