QA Automation Labs

Generate Cucumber .html report in Cypress in Just “5” Steps

1_UH-uIiWHmTvNvwY2uCHLvA

Generate Cucumber .html report in Cypress in Just “5” Steps

Problem statement

We need a .html report where we can see the results of the cucumber cypress test case in graphical form (pie chat etc.)

Solution

With the help of two plugins “cypress-cucumber-preprocessor” and “multiple-cucumber-html-reporter,” we can achieve this

Steps to generate the Cucumber .html report

Step 1: Install the plugin and add the following in the cypress-cucumber-preprocessor section in package.json.npm install — save-dev cypress-cucumber-preprocessor

Add below lines in package.json under the cypress-cucumber-preprocessor section in package.json.“cypress-cucumber-preprocessor”: {
“cucumberJson”: {
“generate”: true,
“outputFolder”: “cypress/cucumber-json”,
“filePrefix”: “”,
“fileSuffix”: “.cucumber
}
}

Detail of pacakage.json fields

Step 2: Run command “yarn run cypress open” and run .feature file Login.cucumber.json the file is generated under the below path.“outputFolder”: “cypress/cucumber-json”,

Login.cucumber.json help us in generating the.html file.

Step 3:Install plugin multiple-cucumber-html-reporter

Install plugin multiple-cucumber-html-reporter plugin with the following commandnpm install multiple-cucumber-html-reporter –save-dev

Step 4: Create .js file (cucumber-html-report.jsin root level which help to read the .json file under (cypress/cucumber-json)*** Let name it cucumber-html-report.js ** const report = require(“multiple-cucumber-html-reporter”); report.generate({ jsonDir: “cypress/cucumber-json”, // ** Path of .json file **// reportPath: “./reports/cucumber-htmlreport.html”, metadata: { browser: { name: “chrome”, version: “81”, }, device: “Local test machine”, platform: { name: “mac”, version: “Catalina”, }, }, });

Step 5: Generate cucumber .html report

Simply run .js file (cucumber-html-report.js) created in above steps. commnd is below

node cucumber-html-report.js

report is generate under reportPath: “./reports/cucumber-htmlreport.html”,

Open the .html (index.html) file in browser

Video for the same attached below

Leave a Comment

Your email address will not be published. Required fields are marked *

Recent Posts

AI-Driven Testing with Applitools Autonomous

The demand for high quality software in the fast paced tech environment has never been greater. Since companies spend more on QA to make sure their pr
Read More

Visual Regression Testing Using Playwright

“Have you ever thought, ‘Why wasn’t that noticed?’ or ‘Is the bug so obvious that it should have been caught right away?
Read More

Cypress vs Selenium: Choosing the Best Tool for Your Automation Needs

Choosing the right testing tool for your project can be a challenging task. Two of the most widely used options are Cypress and Selenium, and understa
Read More