gkushang/cucumber-html-reporter

If cucumber step fails then getting Unable to parse cucumberjs output into json error.

Raghu2010 opened this issue · 0 comments

I am trying to execute simple cucumber scenario with two step definitions, if both the step definitions are passed then the html report is generating properly.
But in case if any one of the step fails then the report is not generating instead it is throwing below error.

"Unable to parse cucumberjs output into json: '%s' results/cucumber-report.json SyntaxError: results/cucumber-report.json: Unexpected end of JSON input"

cucumber-report.json
[
{
"description": "",
"elements": [
{
"description": "",
"id": "login-test-suite;login-scenario",
"keyword": "Scenario",
"line": 3,
"name": "Login scenario",
"steps": [
{
"keyword": "Before",
"hidden": true,
"result": {
"status": "passed",
"duration": 0
}
},
{
"arguments": [],
"keyword": "Given ",
"line": 4,
"name": "User opens the application",
"match": {
"location": "e2e/stepDefinitions/login.steps.js:12"
},
"result": {
"status": "failed",
"duration": 3000000,
"error_message": "AssertionError\n + expected - actual\n\n -true\n +false\n\n at World. (/Users/dq_raghu/PRACTICE_WORKSPACE/axe-report-cucumber/e2e/stepDefinitions/login.steps.js:15:21)"
}
}
],
"tags": [],
"type": "scenario"
}
],
"id": "login-test-suite",
"line": 1,
"keyword": "Feature",
"name": "Login test suite",
"tags": [],
"uri": "e2e/features/login.feature"
}
]

hooks.js
AfterAll(async () => {
await browser.close();
const reporter = require("cucumber-html-reporter");
const options ={
theme:'bootstrap',
jsonFile:'results/cucumber-report.json',
output:'results/cucumber-html-result.html',
reportSuiteAsScenaros:true,
launchReport:false,
}
return reporter.generate(options);

})