Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cucumber JSON report fails to generate when a scenario outline has a tag #1621

Closed
xenbartolokath opened this issue Mar 22, 2021 · 12 comments · Fixed by cucumber/common#1489 or #1651
Closed
Assignees
Labels
🐛 bug Defect / Bug ✅ accepted The core team has agreed that it is a good idea to fix this

Comments

@xenbartolokath
Copy link

xenbartolokath commented Mar 22, 2021

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.

@aurelien-reeves
Copy link
Contributor

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?

@xenbartolokath
Copy link
Author

xenbartolokath commented Mar 23, 2021

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!

@aslakhellesoy aslakhellesoy added the 🐛 bug Defect / Bug label Mar 23, 2021
@aslakhellesoy aslakhellesoy added this to Next in Cucumber Open via automation Mar 23, 2021
@aurelien-reeves
Copy link
Contributor

Thanks for the info @xenbartolokath

@yopasa94
Copy link

yopasa94 commented Apr 12, 2021

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

@aurelien-reeves
Copy link
Contributor

Thanks for your feedback @yopasa94 👍

@aurelien-reeves aurelien-reeves added the ✅ accepted The core team has agreed that it is a good idea to fix this label Apr 14, 2021
@aurelien-reeves aurelien-reeves moved this from Next to In Progress in Cucumber Open Apr 19, 2021
@aurelien-reeves aurelien-reeves self-assigned this Apr 19, 2021
@aurelien-reeves
Copy link
Contributor

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?

@xenbartolokath
Copy link
Author

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

@aurelien-reeves
Copy link
Contributor

FYI the standalone json-formatter is a standalone binary written in go. It does not require any installation beside making sure it is executable.

@xenbartolokath
Copy link
Author

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

@aurelien-reeves
Copy link
Contributor

A fix has been merged in the new standalone json-formatter
But I'll try to fix the legacy built-in formatter too

@aurelien-reeves aurelien-reeves added this to Next in Cucumber Open via automation Apr 21, 2021
@aurelien-reeves
Copy link
Contributor

@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 aurelien-reeves moved this from Next to In Progress in Cucumber Open Apr 23, 2021
Cucumber Open automation moved this from In Progress to Implemented Apr 26, 2021
aurelien-reeves added a commit that referenced this issue Apr 26, 2021
* Add a reproduction scenario for #1621

* Add a unit test

* Fix the json-formatter to make tests pass

* [skip ci]Update changelog
@xenbartolokath
Copy link
Author

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

@mattwynne mattwynne moved this from Implemented to Released in Cucumber Open Sep 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Defect / Bug ✅ accepted The core team has agreed that it is a good idea to fix this
Projects
Archived in project
4 participants