Cypress is a next generation front end testing tool built for the modern web with software tool that supports behavior-driven development cucumber.
Before using cypress with cucumber, you need to install node.js, install all the dependencies for doing the full operation of the node.js.
Download git repository
git clone https://github.com/Diankavoy19/Cypress-cucumber
and use install node modules.
Dependencies:
- cypress
- cypress-cucumber-preprocessor
- multiple-cucumber-html-reporter
- @cypress/browserify-preprocessor
You need to add following to package.json
{
"dependencies": {
"@badeball/cypress-cucumber-preprocessor": "latest"
},
"cypress-cucumber-preprocessor": {
"json": {
"enabled": true,
"output": "jsonlogs/log.json",
"formater": "cucumber-json-formatter.exe"
},
"messages": {
"enabled": true,
"output": "jsonlogs/messages.ndjson"
}
}
and configure cypress.config.js
const { defineConfig } = require("cypress");
const preprocessor = require("@badeball/cypress-cucumber-preprocessor");
const browserify = require("@badeball/cypress-cucumber-preprocessor/browserify");
async function setupNodeEvents(on, config) {
await preprocessor.addCucumberPreprocessorPlugin(on, config);
on("file:preprocessor", browserify.default(config));
// Make sure to return the config object as it might have been modified by the plugin.
return config;
}
module.exports = defineConfig({
e2e: {
specPattern: "**/*.feature",
supportFile: false,
setupNodeEvents,
},
});
Also you need to download cucumber-json-formatter according to your OS and rename this file to
cucumber-json-formatter.exe
After that we can run all our tests.
npm run cypress:open
or
npx cypress:run
or with config file for macbook-15
npm run cypress:config
Also we can generate reports
npm run cypress:report