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

[Discussion] Should scenarios be a single test ? #43

Closed
BenoitAverty opened this issue Apr 17, 2018 · 3 comments
Closed

[Discussion] Should scenarios be a single test ? #43

BenoitAverty opened this issue Apr 17, 2018 · 3 comments

Comments

@BenoitAverty
Copy link
Contributor

Hello,

Currently, each step in a scenario becomes a single test in cypress. This is expected and this is the way other cucumber frameworks do it.

However, this goes against cypress recommendations and best bractices because they consider that each test should be independant and able to run alone. This is kind of incompatible with cucumber behavior.

It is not only a "best practice" issue because cypress clears a lot of things between tests : cookies, local storage, session storage, spies, stubs...
This means, for example, I can't set-up a mock in a given step and rely on it in a subsequent when or then.

Possible solutions :

  • Make each scenario produce a single test (and Background would become beforeEach, but this would hurt reporting)
  • somehow preserve state for a scenario (currently, cypress only allows to do it for cookies)

See :

What do you think ?

@lgandecki
Copy link
Collaborator

Fixed in 1.0.0 :) Again - Thanks so much!

@manishbhatia7
Copy link

Hello,

Currently, each step in a scenario becomes a single test in cypress. This is expected and this is the way other cucumber frameworks do it.

However, this goes against cypress recommendations and best bractices because they consider that each test should be independant and able to run alone. This is kind of incompatible with cucumber behavior.

It is not only a "best practice" issue because cypress clears a lot of things between tests : cookies, local storage, session storage, spies, stubs...
This means, for example, I can't set-up a mock in a given step and rely on it in a subsequent when or then.

Possible solutions :

  • Make each scenario produce a single test (and Background would become beforeEach, but this would hurt reporting)
  • somehow preserve state for a scenario (currently, cypress only allows to do it for cookies)

See :

  • cypress-io/cypress#686 (second solution would become possible if they implement this but it doesn't look like it's going to be soon).
  • cypress-io/cypress#461 (allows to keep local storage, but it's hacky and doesn't solve other things being cleared)

What do you think ?

Is this issue solved,
Can we write multiple files with same session for cucumber with cypress

@dozzzzer
Copy link

How do you preserve cookies through steps? I need to stay logged in within the entire scope of the scenario. I tried Cypress.Cookies.preserveOnce('_session') inside the step definition where log in is performed but it doesn't seem to work. Any help with that is much appreciated :)

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

No branches or pull requests

4 participants