cypress-cucumber-preprocessor icon indicating copy to clipboard operation
cypress-cucumber-preprocessor copied to clipboard

Support Cucumber Html Reporter

Open KingCode-W opened this issue 7 years ago • 22 comments

I think it would be awesome to add support for cucumber html reporter. As it currently works, it's not able to take the report generated by mochaweseome and even then, tests ran in cucumber are are output as if (backgroundSection) { backgroundSection.steps.forEach(step => stepTest.call(this, step)); } scenario.steps.forEach(step => stepTest.call(this, step));

Maybe I'm missing something but the error I recieved when trying to generate a cucumber-html-report was

TypeError: suite.features.forEach is not a function

KingCode-W avatar Apr 03 '19 16:04 KingCode-W

when I expand scenario outline in html report it displays like below instead of actual steps if (backgroundSection) { backgroundSection.steps.forEach(step => { stepTest.call(this, step); }); } scenario.steps.forEach(step => { const newStep = Object.assign({}, step); newStep.text = replaceParameterTags(rowData, newStep.text); stepTest.call(this, newStep); }); Am I missing something here?

smithabethi avatar May 03 '19 19:05 smithabethi

I too see the same issue. I think we don't have the support of Cucumber completely yet with Cypress + mochawesome Reports.

moinuddin14 avatar May 27 '19 11:05 moinuddin14

I think it would be a great addition

KingCode-W avatar May 27 '19 12:05 KingCode-W

up

gabrielfign avatar Jun 21 '19 13:06 gabrielfign

expecting

chenhaizhou avatar Jun 28 '19 02:06 chenhaizhou

https://github.com/jcundill/cypress-cucumber-preprocessor/tree/rebaseupstream

https://github.com/jcundill/cypress-cucumber-preprocessor/tree/rebaseupstream#cucumberjson-file-generation

You can try this, it's been working well for our needs internally for a while now - if it's useful I'll raise a PR

jcundill avatar Jul 02 '19 06:07 jcundill

@jcundill, thanks for the wonderful effort. I tried using it but I am always getting an empty json file generated. The naming convention is not exact, its always coming as "cucumber-C" (suffix is ignored) Config:

..
"cypress-cucumber-preprocessor": {
    "cucumberJson": {
      "generate": true,
      "outputFolder": "cucumber-json",
      "filePrefix": "cucumber-",
      "fileSuffix": "a.json"
    }
 }

avais88786 avatar Jul 02 '19 21:07 avais88786

Thanks for the feedback - you are right seems that the json file suffix stuff is not working correctly - however we are getting properly generated cucumber.json files from this - do you maybe want to raise an bug against my fork and post some minimal config to reproduce the empty file issue so I can track your problem down.

Screenshot 2019-07-02 at 23 50 52

jcundill avatar Jul 02 '19 22:07 jcundill

@jcundill thanks for your reply. I tried a lot of scenarios: deleting node modules and reinstalling, change feature file name, move feature file location, etc. Everything seem to generate the empty file. I have raised a bug against your fork, please look into this, looking forward to using it, in fact we are going to be using commercially with a large team so cheers for all help. Bug link: https://github.com/jcundill/cypress-cucumber-preprocessor/issues/8

avais88786 avatar Jul 03 '19 18:07 avais88786

Strongly expecting this

ldsenow avatar Jul 04 '19 00:07 ldsenow

@jcundill, thanks for the cucumber JSON generation with cypress. it's working perfectly. And also I am able to generate the HTML report with "multi cucumber reporter"

Here I wanted to check with you how I can attach some text/screenshot to the report.

For Example: https://github.com/cucumber/cucumber-js/blob/HEAD/docs/support_files/attachments.md

Satya-Gorla avatar Jul 06 '19 02:07 Satya-Gorla

@sagorla Text describing the failure should already be in the report for failing and missing steps If this is not the case for you, please raise an issue against my fork and I'll fix it up.

Screenshot 2019-07-06 at 07 53 01

jcundill avatar Jul 06 '19 06:07 jcundill

Screenshots can be generated a couple of ways

  1. using cy.screenshot - I haven't added support for this to my fork, should be doable fairly easily by getting the onAfterScreenshot to feed the image data to the cucumber JSON data collector object.

  2. automated screen shots (and videos) of failed tests directly from cypress.

This second option is what we wanted to try and include in our reports, and we especially wanted to embed the videos. Unfortunately the video generation is kicked off after the test has finished, and after the mocha reporter hook has also finished.

So we ended up writing a simple script that can be added to our jenkins build pipeline that augments the cucumber.json files with these images and videos after all the features have been run.

https://github.com/jcundill/cypress-cucumber-preprocessor/blob/master/fixJson.js

This may be helpful for you.

I'll try and take a look at supporting cy.screenshot() it would be a good addition

jcundill avatar Jul 06 '19 07:07 jcundill

@avais88786 Everything should be working fine on Windows boxes now, I fixed and closed https://github.com/jcundill/cypress-cucumber-preprocessor/issues/8

Please let me know if you are still having issues here

jcundill avatar Jul 06 '19 07:07 jcundill

Thanks, @jcundill for your quick replay.

you are right "Text describing the failure" and "Failing steps missing" are coming through the report.

it would very helpful if you support cy.screenshot & cy.log().

Satya-Gorla avatar Jul 06 '19 13:07 Satya-Gorla

Thanks @jcundill for the quick fix and apologies for late reply. I can confirm this now works as expected on windows and my scenarios. Can we have your branch merged on master please?

avais88786 avatar Jul 10 '19 09:07 avais88786

This is done and released thanks to @jcundill !

lgandecki avatar Sep 25 '19 08:09 lgandecki

Is it possible to have the report executed right after the test so we don't have to manually run the script to produce the HTML report?

tvutx avatar Mar 04 '20 14:03 tvutx

Anyone know how to generate cucumber-json reports with screenshot and also cucumber html reports with screenshot please, I would be very grateful? of the suggestions that I have read, none have generated the cucumber-json report, nor the html with screenshots.

gretherMG avatar Mar 26 '21 16:03 gretherMG

any solution please, someone managed to add screenshot to cucumber json, any ideas?

gretherMG avatar Mar 31 '21 19:03 gretherMG