badeball / cypress-cucumber-preprocessor

Run cucumber/gherkin-syntaxed specs with Cypress
MIT License
1.32k stars 147 forks source link

Wanted to have the json logs without json-formatter.exe so that cucumber report can be generated #850

Closed Keyur90 closed 1 year ago

Keyur90 commented 2 years ago

Current behavior

Unable to get the logs without using json-formatter.exe

Desired behavior

I wanted to get the logs in JSON file of my last test run so that I can generate a cucumber report running on the agent through the CI pipeline. I can not check in json-formatter.exe so wanted eliminate the json-formatter.exe file usage.

Test code to reproduce

Versions

Checklist

WTK commented 2 years ago

That's probably not going to happen as this preprocessor relies on cucumber-json-formatter completely for json output (parsing cucumber messages to json format). That said, I'd love to hear from @badeball if there are ANY alternatives given that cucumber-json-formatter has several bugs (reported by him as well) that are stale since May.

sagar-maheshwari commented 2 years ago

I've been using https://github.com/Vitalizzzer/cucumber-json-report-formatter

It consumes the messages file and generates the JSON without the need for a formatter. However, they have an open issue where the step duration shows incorrectly, however, if it doesn't bother you, you can try this out.

WTK commented 2 years ago

Awesome, thanks for the tip, I'll try it out!

Keyur90 commented 2 years ago

I've been using https://github.com/Vitalizzzer/cucumber-json-report-formatter

It consumes the messages file and generates the JSON without the need for a formatter. However, they have an open issue where the step duration shows incorrectly, however, if it doesn't bother you, you can try this out.

Hey Sagar, thanks for referring to this. Do you mind if you can show me how have you used this? What I did is I created a file formatter.js and provided the below code within the same. (don't bother about the location)

import {Formatter} from 'cucumber-json-report-formatter';

const formatter = new Formatter() const sourceFile = "./cucumber-messages.ndjson" const outputFile = "./reports/cucumber-report.json" await formatter.parseCucumberJson(sourceFile, outputFile)

sagar-maheshwari commented 2 years ago

You can run the js file using node after your test execution is finished, but the easiest way is to amend the configuration in .cypress-cucumber-preprocessorrc.json or package.json as below:

image

Keyur90 commented 2 years ago

You can run the js file using node after your test execution is finished, but the easiest way is to amend the configuration in .cypress-cucumber-preprocessorrc.json or package.json as below:

image

I tried this but it is expecting to run cucumber-json-formatter and looking for that exe in the after:run tag event image

jaxfellow commented 2 years ago

@Keyur90 I guess we have the same problem, as described here #851

sagar-maheshwari commented 2 years ago

You can run the js file using node after your test execution is finished, but the easiest way is to amend the configuration in .cypress-cucumber-preprocessorrc.json or package.json as below: image

I tried this but it is expecting to run cucumber-json-formatter and looking for that exe in the after:run tag event image

Do you have a after:run event in your config? If yes, you'd need to amend it. example here: https://github.com/badeball/cypress-cucumber-preprocessor/issues/805#issuecomment-1218399297

badeball commented 1 year ago

I can not check in json-formatter.exe so wanted eliminate the json-formatter.exe file usage.

I don't expect anyone to check this into VCS anymore than I expect you to check Node into it and that's fairly unheard of. I'm using it Gitlab actions myself, without any issues: https://github.com/badeball/cypress-cucumber-preprocessor/blob/master/.github/workflows/build.yml

Despite this, I do intend to replace it in time: https://github.com/badeball/cypress-cucumber-preprocessor/issues/870