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

feat: add support for cypress-cucumber-preprocessor #172

Merged
merged 5 commits into from
Dec 29, 2023

Conversation

mistic100
Copy link
Contributor

@mistic100 mistic100 commented Dec 12, 2023

This solves #130

Users of cypress-cucumber-preprocessor will be able to import cucumberSupport in their steps in order to store the gherkin AST in the test context. During the report generation the context will be used to remplace the code by the actual gherkin.

I tried to keep the modification as light as possible without adding any required dependencies.

  • @badeball/cypress-cucumber-preprocessor is only imported in cucumberSupport.js
  • @cucumber/gherkin-utils is imported inside a try-catch block in enhanceReport.js

All of this is optionnal allowing to mix Cucumber features and standard tests in the same suite.


There is still need to add tests, for now I cannot tell when I will be able to do it.

@LironEr
Copy link
Owner

LironEr commented Dec 14, 2023

Hey, thanks for the PR. It looks great!

I started to add example & some changes to the README file, but I don't have permissions to the fork, can you please give me push permissions?
If that's a problem please look at this commit 1c476b5

If you could add some scenarios (some success and some fail), I can create the tests afterward - as I'm unfamiliar with cucumber.

Also just wanted to make sure that this is the output you want
image

Thanks.

@mistic100
Copy link
Contributor Author

Hey, thanks for the PR. It looks great!

Thank for taking time to look at this :)

I started to add example & some changes to the README file, but I don't have permissions to the fork, can you please give me push permissions?

It seems this is not possible from forks made on an organization https://github.com/orgs/community/discussions/5634

You could cherry-pick my commits and just discard this PR once it is done. I don't really care.

If you could add some scenarios (some success and some fail), I can create the tests afterward - as I'm unfamiliar with cucumber.

Yes of course. I'll try to that for next week.

Also just wanted to make sure that this is the output you want

Yes that's what I expect. The code highlight is not working because it expects JS/TS but that's not really critical, at least for my needs. And it's something to fix/configure in mochawesome anyway, not in the reporter.

@mistic100
Copy link
Contributor Author

I just saw that there is not need to grab the gherkinDocument from window.

It is already passed to Before hooks https://github.com/badeball/cypress-cucumber-preprocessor/blob/master/docs/cucumber-basics.md#scenario-hooks

@LironEr LironEr changed the title add support for cypress-cucumber-preprocessor feat: add support for cypress-cucumber-preprocessor Dec 16, 2023
@mistic100
Copy link
Contributor Author

@LironEr I added a base example. Tried to understand how your output test works but got no luck :)

I added a note on the README to suggest to use cypress-on-fix module because cypress-cucumber-preprocessor uses the same hooks as cypress-mochawesome-reporter. It is possible to do it manually but much more simplier with this module.

I also have a issue to fix : on the failed job I see the Cucumber source AND the __cucumber_source__ context. I wonder if this is because there is a retry.

Capture d’écran du 2023-12-21 11-34-01

@mistic100
Copy link
Contributor Author

Fixed the mentionned issue : it was caused by duplicate context variable (one for each attempt)

Also added a "Scenario Outline" to test this specific case

@mistic100
Copy link
Contributor Author

mistic100 commented Dec 21, 2023

Had a case where "context" was not an array but a single item (it was a non cucumber failing test)

"context": "{\n  \"title\": \"cypress-mochawesome-reporter-screenshots\",\n  \"value\": [\n    [\n      \"/plugins.cy.ts/plugins -- jms (failed).png\"\n    ]\n  ]\n}",

I added a condition in enhanceReport.js to handle this case

@LironEr LironEr merged commit 3041fd7 into LironEr:master Dec 29, 2023
1 of 2 checks passed
@LironEr
Copy link
Owner

LironEr commented Dec 29, 2023

Thank you @mistic100

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants