Cucumber Version: 7.0.0
Node Version: 14.15.0
Operating System: MacOS Big Sur v11.2.1
Given this following test case:
@parent_tag
Scenario Outline: Sample test case
Given this is a test case
When I have the following data table
| <scenario_example> |
Then a JSON report will be generated
@child_tag_1
Examples:
| scenario_example |
| Test Child Tag 1 |
@child_tag_2
Examples:
| scenario_example |
| Test Child Tag 2 |
When I run the test case above with the tag: "--tags @child_tag_2" and "-f json:reports/cucumber-report.json", the test case runs successfully, but upon generating an report, the following error occurs:
TypeError: Cannot read property 'location' of undefined
at /Users/project-folder/node_modules/@cucumber/cucumber/lib/formatter/json_formatter.js:185:34
at arrayMap (/Users/project-folder/node_modules/lodash/lodash.js:653:23)
at Function.map (/Users/project-folder/node_modules/lodash/lodash.js:9622:14)
at JsonFormatter.getScenarioTags (/Users/project-folder/node_modules/@cucumber/cucumber/lib/formatter/json_formatter.js:180:33)
at JsonFormatter.getScenarioData (/Users/project-folder/node_modules/@cucumber/cucumber/lib/formatter/json_formatter.js:125:24)
at /Users/project-folder/node_modules/@cucumber/cucumber/lib/formatter/json_formatter.js:84:29
at Array.map (<anonymous>)
at /Users/project-folder/node_modules/@cucumber/cucumber/lib/formatter/json_formatter.js:69:36
at /Users/project-folder/node_modules/lodash/lodash.js:3585:27
at /Users/project-folder/node_modules/lodash/lodash.js:4967:15
at baseForOwn (/Users/project-folder/node_modules/lodash/lodash.js:3032:24)
at /Users/project-folder/node_modules/lodash/lodash.js:4936:18
at baseMap (/Users/project-folder/node_modules/lodash/lodash.js:3584:7)
at Function.map (/Users/project-folder/node_modules/lodash/lodash.js:9622:14)
at JsonFormatter.onTestRunFinished (/Users/project-folder/node_modules/@cucumber/cucumber/lib/formatter/json_formatter.js:63:43)
at EventEmitter.<anonymous> (/Users/project-folder/node_modules/@cucumber/cucumber/lib/formatter/json_formatter.js:23:22)
Therefore I can't generate any JSON report.
I tried removing the scenario outline example tags and it proceeded with generating the JSON report.
Hi :)
When you say "I tried removing the scenario outline example tags and it proceeded with generating the JSON report.", did you removed only the tags but keep two examples tables? Or did you merge both Examples into one?
Hi @aurelien-reeves,
I removed both the tags and the two examples table, and just used 1 examples table. :) Something like this:
@parent_tag @child_tag_2
Scenario Outline: Sample test case
Given this is a test case
When I have the following data table
| <scenario_example> |
Then a JSON report will be generated
Examples:
| scenario_example |
| Test Child Tag 2 |
Many thanks!
Thanks for the info @xenbartolokath
I got the same issue but I realized that I was filtering when I run the cli command I.E
npm run protractor -- --cucumberOpts.tags='not (@wip or @bug or @backlog) and @blocker'
I had a different tag in the example table
@another_tag
Examples:
| scenario_example |
| Test Child Tag 2 |
I changed the command to this and work for me-->
npm run protractor -- --cucumberOpts.tags='not (@wip or @bug or @backlog) and (@blocker or @another_tag)'
Thanks for your feedback @yopasa94 馃憤
I have investigated the issue further.
Indeed, the json formatter does not support tags on examples. It actually should.
The new json-formatter does not help here. It does not recognize examples tags either.
As the built-in json formatter is deprectated, I will focus on fixing the new standalone one.
@xenbartolokath @yopasa94 do you have specific need in using the legacy deprecated formatter? Or anything else which would prevent you to use the new standalone json formatter?
Which version of cucumber are you using?
Hi @aurelien-reeves,
For this issue, I was using @cucumber/cucumber v7.0.0, but I still use v6.0.5 on other repositories that I have.
I don't have specific need in the legacy deprecated formatter. For the standalone json formatter, I saw that I needed to download and execute some commands to install it, and I don't know if my pipeline's current setup would accommodate the changes. I prefer installing it via npm if available.
As long us I can put tags on Examples tables and generate reports without problems, then I'm good with it. 馃槂
FYI the standalone json-formatter is a standalone binary written in go. It does not require any installation beside making sure it is executable.
FYI the standalone json-formatter is a standalone binary written in go. It does not require any installation beside making sure it is executable.
Got it. Thanks for the clarification. 馃槉
A fix has been merged in the new standalone json-formatter
But I'll try to fix the legacy built-in formatter too
@xenbartolokath @yopasa94 The standalone json-formatter has just been released with the support of tagged examples.
You can download it there: https://github.com/cucumber/cucumber/releases/tag/cucumber-json-formatter%2Fv17.0.2
@aurelien-reeves Will try this out and will let you know if there are some feedbacks from my end. Thank you! Appreciated your time and effort 馃槉
Most helpful comment
A fix has been merged in the new standalone json-formatter
But I'll try to fix the legacy built-in formatter too