multiple-cucumber-html-reporter icon indicating copy to clipboard operation
multiple-cucumber-html-reporter copied to clipboard

Failed `Before` hook not present in report

Open Llois41 opened this issue 1 year ago • 6 comments

Environment (please complete the following information)

  • multiple-cucumber-html-reporter: 3.6.2
  • Node.js version: 20.15.1
  • NPM version: yarn v4.3.0
  • Cucumber version: 10.8.0

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.

Llois41 avatar Jul 22 '24 11:07 Llois41

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.

Duez-Yoan avatar Jul 31 '24 15:07 Duez-Yoan

@Llois41 , @Duez-Yoan ,

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

WasiqB avatar Aug 05 '24 16:08 WasiqB

@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.

Llois41 avatar Aug 05 '24 17:08 Llois41

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

WasiqB avatar Aug 05 '24 18:08 WasiqB

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 :)

Duez-Yoan avatar Aug 06 '24 15:08 Duez-Yoan

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

WasiqB avatar Aug 06 '24 15:08 WasiqB