json-formatter icon indicating copy to clipboard operation
json-formatter copied to clipboard

Inaccurate output of `match` on undefined step definition

Open badeball opened this issue 3 years ago • 0 comments

👓 What did you see?

There's a difference in outputted JSON from cucumber-js compared to its messages piped through cucumber-json-formatter.

✅ What did you expect to see?

The JSON output of cucumber-js in case of an undefined step is as following.

[
  {
    "description": "",
    "elements": [
      {
        "description": "",
        "id": "a-feature;a-scenario",
        "keyword": "Scenario",
        "line": 2,
        "name": "a scenario",
        "steps": [
          {
            "arguments": [],
            "keyword": "Given ",
            "line": 3,
            "name": "a missing definition",
            "result": {
              "status": "undefined",
              "duration": 0
            }
          }
        ],
        "tags": [],
        "type": "scenario"
      }
    ],
    "id": "a-feature",
    "line": 1,
    "keyword": "Feature",
    "name": "a feature",
    "tags": [],
    "uri": "features/foo.feature"
  }
]

However, when piping the messages output through cucumber-json-formatter I get the following.

[
  {
    "description": "",
    "elements": [
      {
        "description": "",
        "id": "a-feature;a-scenario",
        "keyword": "Scenario",
        "line": 2,
        "name": "a scenario",
        "steps": [
          {
            "keyword": "Given ",
            "line": 3,
            "name": "a missing definition",
            "result": {
              "status": "undefined"
            },
            "match": {
              "location": "features/foo.feature:3"
            }
          }
        ],
        "type": "scenario"
      }
    ],
    "id": "a-feature",
    "keyword": "Feature",
    "line": 1,
    "name": "a feature",
    "uri": "features/foo.feature"
  }
]

Notice the diff (using json-diff).

 [
   {
-    tags: [
-    ]
     elements: [
       {
-        tags: [
-        ]
         steps: [
           {
-            arguments: [
-            ]
+            match: {
+              location: "features/foo.feature:3"
+            }
             result: {
-              duration: 0
             }
           }
         ]
       }
     ]
   }
 ]

📦 Which tool/library version are you using?

  • cucumber-js: 8.1.2
  • cucumber-json-formatter: 19.0.0

🔬 How could we reproduce it?

Steps to reproduce the behavior:

  1. git clone https://github.com/badeball/reproducible-issues.git
  2. cd reproducible-issues/cucumber/undefined-step
  3. npx @cucumber/cucumber
  4. npx json-diff report.json <(cat report.ndjson | cucumber-json-formatter)

📚 Any additional context?

The samme problem exist for ambiguous steps as well. The same steps can be run, just in the ambiguous-step of the above-mentioned repository.

badeball avatar Apr 27 '22 19:04 badeball