-
Notifications
You must be signed in to change notification settings - Fork 118
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
Reports in json #27
Comments
Agreed that jest-junit and other reporters aren't really sufficient. I am planning to look into creating a plug-in that will output Cucumber JSON when I get some time. |
Any tentative date on #27 enhancement? |
@martotkd1 Appreciate if you could provide any ETA on the reporting front ? |
Yes I agree it would be great if there could be an ETA provided for this enhancement |
Improved reporting is the most commonly requested feature at this point, so this will definitely be next on the list, and I have already started some initial prototyping. |
I have been working on this here and there as I have spare time, and at this point, I have published an early preview version (2.0.12). It has still has some known issues I'm working to resolve, but it at least shows off what it can do. The default setup in your Jest configuration looks like this: "reporters": [
"./node_modules/jest-cucumber/dist/src/reporter"
], With the defaults, it will output A custom output path can be specified like so: "reporters": [
"default",
["./node_modules/jest-cucumber/dist/src/reporter", {
"formatter": "json",
"path": "./reports/test-report.json"
}]
], The reporter works by using the Cucumber Event Protocol and formatters from Cucumber.js. This means that it is technically possible to use any formatter from Cucumber.js, but not all of them make sense with Jest. In addition to the JSON formatter, the progress and summary formatters are also supported. The summary formatter outputs to the console at the end of a test run and shows which specific steps failed (if any), along with the number of scenarios / steps and the run-time. "reporters": [
"default",
["./node_modules/jest-cucumber/dist/src/reporter", {
"formatter": "summary"
}]
], The progress formatter does everything the summary formatter does, but it shows the progress of your steps as well with colored dots for passing steps, "F" for skipped steps, "S" for skipped steps, etc. It is recommended that this be used without the default Jest reporter, since its output will get mixed in with the default reporter output otherwise: "reporters": [
["./node_modules/jest-cucumber/dist/src/reporter", {
"formatter": "progress"
}]
], Known issues:
|
Hi, I downloaded the code from the branch "reporting", to see if I can help you, but I'm sorry, I'm a newbie with TypeScript/nodeJS. I see, that you are generating events to cucumber.js. Can you have a look at the serenity-js Maybe it is possible to integrate your solution with SerenityJS? They have pretty and detailed reports. Thank you for your work! |
@s2oBCN - In addition to having the few built-in formatters listed above, I was also considering allowing custom formatter plug-ins. I haven't worked with SerenityJS, but looking at the code, it appears that serenity-cucumber listens for Cucumber events and calls the Serenity API appropriately. Something similar could probably be accomplished with a custom formatter plug-in. |
Do you think is it possible to have the tags in the json file? |
@s2oBCN - Any tags in your feature files currently will output to the JSON file as expected. Is that what you were asking? For example, consider this feature file with these tags: @feature-test
Feature: Rocket Launching
@scenario-test
Scenario: Launching a SpaceX rocket
... The following JSON will be generated: {
"keyword": "Feature",
"name": "Rocket Launching",
"line": 2,
"id": "rocket-launching",
"tags": [
{
"name": "@feature-test",
"line": 1
}
],
"uri": "/git/jest-cucumber/examples/typescript/specs/features/basic-scenarios.feature",
"elements": [
{
"id": "rocket-launching;launching-a-spacex-rocket",
"keyword": "Scenario",
"line": 5,
"name": "Launching a SpaceX rocket",
"tags": [
{
"name": "@feature-test",
"line": 1
},
{
"name": "@scenario-test",
"line": 4
}
],
"type": "scenario",
"steps": [
... |
Yes, I'm sorry, I executed some tests but I didn't find the tags in the json file. I suppose I was wrong, sorry. So, when do you think we will have this code in a release? :) |
Hi @bencompton This looks great in terms of the output report it produces and the flexibility if offers in terms of format. I just wanted to give some feedback in relation to minor issue I saw. So the only thing I noticed is that there is now a restriction in relation to the length of Scenario name, that I don't think was there previously (or at least it has reduced). I got about 4 failure in relation to that but the fix was obvious by just decreasing the length of scenario name. Not sure exactly what the threshold for the length is, as I just chopped off 20(ish) characters to make it pass.. Here is one of ones I had that caused the failure: 'Sign up confirmation banners displayed on the top of Electronic Signature page when user select's Sign up option on Login page when User select to sign up before submitting application' Just wondering about the correct fix. Would it be for me to shorten the offending Scenario names OR would a resolution to first Known issue (cleaner reference to jest-cucumber-reporting node_module) you have specified solve it? Will provide screenshot with error |
Great news!!!! About the error, I see, there's a file per scenario, I suppose this is the only way. In another approach (in a Java project), I generated a file per feature (with the name of the feature), but I suppose this is not possible here. Can you push the code in order to test it? |
I see an issue, when executing "Scenario Outline", if you change the sample:
By: (So we will have allways the same title) Then, the JSON report will only show result of the last Example of the Scenatio Outline. Another thing, in other frameworks I can see the JSON when "Scenario Outline" with: I can see in the Cucumber.js project in the "keyword":"Scenario" is hardcoded, this is different from the implementation in Java. But, of course, this is not related to this project. |
@bdjos1 and @s2oBCN - thanks for the feedback! Yes, unfortunately, it has to write info about each scenario to a file because there isn't really another option with the way Jest's parallel execution works. I looked into hooking into the event mechanism that Jest itself uses to communicate between worker processes, but it turned out that would interfere with Jest. Could try another method of interprocess communication, or the file name could be a hash or something at least. The scenario outline only showing the last example title is definitely an issue. Not sure why the Cucumber.js formatter splits up scenario outlines into separate scenarios, or whether there is a way to fix it. For people using the JSON to generate a living documentation website, this would be annoying to have the report not match the feature file.
Sorry, not sure I follow. It's already published on NPM v2.0.12, or are you referring to something else? |
Ops! Yes, I see that is in v2.0.12. As I could not see the code in the master branch, I didn't realize that there was a release Now, I will try to find the way distinguish both cases "Scenario Outline"/"Scenario", because I have a process that generates the test cases in Jira, from the execution report, and we use the tags to create fields like "data creation"/"Reviewer".... And we treat as only one testCase all the samples from a Scenario Outline. Meanwhile, I deepened in your code, and I like it very much. I think it's a very smart and simple solution, the way of interact Jest with Cucumber. |
@s2oBCN - glad the project is useful to someone! Yeah, definitely need to see if there is a way to make it not split up scenario outlines into separate scenarios. |
Is someone working on creating the report? It is to start creating it or helping it. |
Hi @bencompton, I'm using the whole lib (thanks for open sourcing it!), the reporting feature included and the only disturbing issue what I have at the moment is with skipping tests. This means, I cannot use any tags at the moment. ● Test suite failed to run
TypeError: Cannot read property 'steps' of undefined
at TestCaseEventGenerator.generateTestCasePreparedEvent (node_modules/jest-cucumber/src/reporting/report-event-generation/TestCaseEventGenerator.ts:22:19)
at node_modules/jest-cucumber/src/reporting/report-event-generation/ReportEventGenerator.ts:34:43
I saw that
Can I help here somehow? I would like to be able to include the skipped scenarios in the report, I think the information that specs are skipped belong in every report. This is why I would like to help to get this working. As I see the error thrown by skipped scenarios occurs because the eventDataCollector.pickleMap does not contain anything about the skipped steps. I think if every skipped step would be still saved to the map with default values like startTime = endTime = 0, error = null, (maybe a state "skipped" ??) the problem could disappear. |
Hey @bencompton, I am using 3.0 and having difficulties generating a json file. Have the reporting changes been incorporated in master? Or 2.0.12 is still the only one that works? |
Reporting was an experimental feature that unfortunately hasn't panned out so far and currently only works in 2.0.12, though it's buggy. I really wanted to finish up reporting for 3.0, but I ran into some issues that made it not so feasible:
Long story short, reporting has fatal flaws and would need to be completely rewritten. My main motivation for JSON reporting is living documentation, and I started messing around building an open source living documentation and example mapping tool a while back, but it's hard to find time to devote to such endeavors. |
@yellowbrickc @martotkd1 @cappelaere @s2oBCN @hemantaK @7agustibm you should check out cucumber-jest, it's a jest transformer that allows you to use cucumber's api for defining steps, hooks, world, etc. The output includes example tables (scenario outlines), tables, and doc strings. |
Thanks @mentierd for the suggestion |
Hi @mainfraame |
it's a spam |
Thanks @nicodinh |
Hi @bencompton, Cucumber maintainer here 👋. Thanks for all your work bringing Cucumber love to the Jest community! If there's anything we can do from our end to make Cucumber-JS or its internal libraries easier to work with, please come over to https://cucumber.io/community#slack or https://github.com/cucumber/cucumber-js and we'll see how we can help. I know those bits have been through some pretty drastic changes of late, and I know how frustrating it can be trying to maintain tooling against libraries that change so much. Sorry! FWIW I think that change has probably settled down now, and we're back into a state of incremental evolution rather than revolution. We do have an online service now for publishing Cucumber reports: https://reports.cucumber.io/ which works with the new message protocol (They're I'm curious to hear what people are doing with that legacy JSON report format. We thought it was pretty hideous, but I think we've been surprised by the amount of tooling people had been building on top of it. For people in that situation, we've built a CLI tool which can take a stream of the new ndjson messages and pump out a legacy json report. Maybe that could help? |
Another Cucumber maintainer here. FWIW, we're phasing out the JSON report format and replacing it with cucumber messages. You can read more about why on that page.
This is incorrect. The format isn't binary, it's NDJSON. The current implementation uses protobuf's JSON format, but we're removing that - see cucumber/common#1386 |
@mattwynne and @aslakhellesoy, thanks for reaching out! Migrating reporting has been on the backlog for a while mainly due to lack of bandwidth on my part, though if I do find any ways to improve the Cucumber libraries, I'll certainly be in contact. It's good to know that the dust has settled. I suppose the legacy JSON format sufficiently covered a lot of use cases, but the additional capabilities in the new format are quite valuable to the community. The CLI converter definitely helps so that libraries like this one won't have to output both formats.
Thanks, appreciate the clarification! Either way, good to know that it's a more inspectable, textual format. It seems I never noticed the update clarifying the format, and stuck with my invalid assumption that it was binary because it uses protobufs, so my apologies for spreading misinformation. |
So what can we do today to have the |
What about this issue ? Not being able to generate .json reports from jest-cucumber, makes it useless for us when doing CI/CD with Jenkins. |
anyone have an ideas on how to get screenshots embedded to failed steps for reporting? According to cucumberjs docs I should use an After hook like so:
but every time I run the test I get hit with this error:
|
Hey @bencompton,
This does not work now. I am using nodejs v14.x.x and npm v6.x.x. [email protected]
any other way to generate json reports for jest-cucumber? |
How can I get this type of report using jest-cucumber? |
Hello @bencompton ,
I am really interested in jest-cucumber. I compared it to CucumberJS and let's say it covers the must have features.
I saw there are already issues for asking if jest-cucumber can generate reports.json and i think jest-junit does not help me since it can't display the scenario steps.
Can you please let me know if you have something implemented in this direction ?
Regards,
Martin Bogdanov
The text was updated successfully, but these errors were encountered: