WasiqB / multiple-cucumber-html-reporter

Generate beautiful Cucumber HTML reports
https://github.com/WasiqB/multiple-cucumber-html-reporter/blob/main/README.md
MIT License
252 stars 120 forks source link

Failed `Before` hook not present in report #359

Open Llois41 opened 4 months ago

Llois41 commented 4 months ago

Environment (please complete the following information)

Config of multiple-cucumber-html-reporter

import { type Options } from 'multiple-cucumber-html-reporter';

function createGenerateOptions(inputDirectory: string): Options {
  return {
    displayDuration: true,
    displayReportTime: true,
    jsonDir: inputDirectory,
    reportPath: `${inputDirectory}report/`,
    pageTitle: 'UI/E2E Test Report',
    customData: {
      title: 'Run Configuration',
      data: [
        { label: 'Version', value: process.env.PACKAGE_VERSION },
        { label: 'Branch', value: process.env.CI_COMMIT_REF_SLUG },
        { label: 'Date (UTC)', value: new Date().toISOString() },
      ],
    },
  };
}

Describe the bug

When having a Before hook in the .json input file the reporter does not add it to the report even if it has failed. However the After hook is present in the report.

To Reproduce

Use following .json output from the cucumber tests as input for the reporter

[
  {
    "description": "",
    "elements": [
      {
        "description": "",
        "id": "some test id",
        "keyword": "Szenario",
        "line": 9,
        "name": "TC-WEB-ST-01-1: some name",
        "steps": [
          {
            "keyword": "Before",
            "hidden": true,
            "result": {
              "status": "failed",
              "duration": 476208,
              "error_message": "Error: provoke failure\n    at someFile.<anonymous> (file:///Users/xxx/someScript.mjs:1:23)"
            }
          },
          {
            "keyword": "Before",
            "hidden": true,
            "result": {
              "status": "skipped",
              "duration": 0
            }
          },
          {
            "keyword": "Before",
            "hidden": true,
            "result": {
              "status": "skipped",
              "duration": 0
            }
          },
          {
            "keyword": "Before",
            "hidden": true,
            "result": {
              "status": "skipped",
              "duration": 0
            }
          },
          {
            "arguments": [],
            "keyword": "Angenommen ",
            "line": 11,
            "name": "something happened",
            "match": {
              "location": "file:/Users/xxx/someScript.mjs:2:34"
            },
            "result": {
              "status": "skipped",
              "duration": 0
            }
          },
          {
            "keyword": "After",
            "hidden": true,
            "result": {
              "status": "passed",
              "duration": 39500
            }
          },
          {
            "keyword": "After",
            "hidden": true,
            "result": {
              "status": "passed",
              "duration": 622582
            }
          },
          {
            "keyword": "After",
            "hidden": true,
            "result": {
              "status": "passed",
              "duration": 190041
            },
            "embeddings": [
              {
                "data": "Tm90aGluZyB0byBjbGVhbnVw",
                "mime_type": "text/plain"
              }
            ]
          },
          {
            "keyword": "After",
            "hidden": true,
            "result": {
              "status": "passed",
              "duration": 64624
            }
          },
          {
            "keyword": "After",
            "hidden": true,
            "result": {
              "status": "failed",
              "duration": 228791,
              "error_message": "Error: some-error (file:///Users/xxx/someScript.mjs:12:34)\n    at someScript2.mjs (file:///Users/xxx/someScript.mjs:12:34)"
            },
            "embeddings": [
              {
                "data": "",
                "mime_type": "text/plain"
              },
              {
                "data": "",
                "mime_type": "text/plain"
              }
            ]
          }
        ],
        "tags": [
          {
            "name": "@E2E",
            "line": 5
          },
        ],
        "type": "scenario"
      }
    ],
    "id": "some test id",
    "line": 7,
    "keyword": "Funktionalität",
    "name": "TC-WEB-ST-01: some name",
    "tags": [
      {
        "name": "@E2E",
        "line": 5
      }
    ],
    "uri": "features/e2e/some.feature"
  }
]

Expected behavior

The failed Before hook should be present in the report.

Duez-Yoan commented 3 months ago

I don't have Failed hook at all, Before or After are not include in the report. Is it Failed or Passed hook it is the same.

WasiqB commented 3 months ago

@Llois41 , @Duez-Yoan ,

Can you share a sample project GitHub link so I can take a look at this issue?

Llois41 commented 3 months ago

@WasiqB the given JSON is what the latest version of cucumber printed out (shortened and anonymized). What would you need more?

Thanks for having a look into it.

WasiqB commented 3 months ago

Ok, I will check and work on this issue soon.

Duez-Yoan commented 3 months ago

Hi @WasiqB , here is the link of the branch of my project : https://github.com/Duez-Yoan/cucumberJs/tree/driverManager

I added some before OK and After OK and KO. None of them is visible in the report.

Maybe i forgot some configuration or anything else.

Thanks a lot in advance :)

WasiqB commented 3 months ago

Thanks for sharing the sample project. I will look into this issue soon.