Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

294
Views
Unable to generate Cucumber HTML reports on failure

I have created a project framework using Typescript and Cucumber BDD approach. The executions within the project are working and the cucumber html reports are also getting generated when executions are getting passed, but when the things are failing due to some reason(whether assertion reason in my case) the reports are not getting generated within the specified folder.

Below are some key points to look upon;

  • I am using package.json test module perform my executions.

{
  "name": "sampleprojectplaywright",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    
    "test": "cucumber-js features/**/*.feature --require-module ts-node/register --require test.setup.ts --require step-definitions/**/*.ts --parallel 1 -f json:report/report.json && node report.js && type report/report.json"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "@cucumber/cucumber": "^7.3.2",
    "@playwright/test": "^1.19.1",
    "@types/mkdirp": "^1.0.2",
    "@types/node": "^17.0.18",
    "cucumber-html-reporter": "^5.3.0",
    "cucumber-junit": "^1.7.1",
    "cucumberjs-junitxml": "^1.0.0",
    "fs-extra": "^3.0.1",
    "mkdirp": "^0.5.1",
    "mkdirp-promise": "^5.0.1",
    "multiple-cucumber-html-reporter": "^1.19.0",
    "playwright": "^1.19.1",
    "sanitize-filename": "^1.6.1",
    "ts-node": "^10.5.0",
    "typescript": "^4.5.5"
  }
}

  • Below is the code snippet for report.js file(that is generating the reports in the mentioned folders over there)

const reporter = require("cucumber-html-reporter");
const options = {
  theme: "bootstrap",
  jsonFile: "report/report.json",
  output: "report/cucumber-html-report.html",
  reportSuiteAsScenarios: true,
  launchReport: false,
};
reporter.generate(options);

A point to consider is that report.json is getting created in case of failure also but only html report isn't getting created on failure.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

In order to generate html reports in failure please try to add below code in your cucumber.js file.

In common add "--require report.js", This helps in creating in both passed and failed cases

For reference

const common = --require runner/hooks.js --require features/support/steps.js --require report.js;

module.exports = {
default: ${common} features/**/*.feature
};
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!