npm init -y
npm install cypress --save-dev
npx cypress open
npm install @bahmutov/cypress-esbuild-preprocessor --save-dev
npm install @badeball/cypress-cucumber-preprocessor --save-dev
cypress.config.js
const { defineConfig } = require("cypress");
const createBundler = require("@bahmutov/cypress-esbuild-preprocessor");
const preprocessor = require("@badeball/cypress-cucumber-preprocessor");
const createEsbuildPlugin = require("@badeball/cypress-cucumber-preprocessor/esbuild");
module.exports = defineConfig({
e2e: {
setupNodeEvents(on, config) {
on("file:preprocessor",
createBundler({
plugins: [createEsbuildPlugin.default(config)],
}));
preprocessor.addCucumberPreprocessorPlugin(on, config);
return config;
},
specPattern: "**/*.feature",
},
});
package.json
"cypress-cucumber-preprocessor": {
"step_definitions": "cypress/support/step_definitions/",
"nonGlobalStepDefinitions": false
}