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

Allow reusing cy.server() in several tests and hooks #1183

Closed
Sumolari opened this issue Jan 11, 2018 · 4 comments · Fixed by #4176
Closed

Allow reusing cy.server() in several tests and hooks #1183

Sumolari opened this issue Jan 11, 2018 · 4 comments · Fixed by #4176
Assignees
Labels
pkg/driver This is due to an issue in the packages/driver directory type: feature New feature that does not currently exist

Comments

@Sumolari
Copy link

Is this a Feature or Bug?

Feature.

Current behavior:

cy.server() is reset after each test case (it) is run. This makes impossible things like this:

describe
-> before :: something that needs to wait for a XHR request
-> it :: several tests waiting for requests

We could do:

describe
-> before :: set up cy.server()
-> before :: something that needs to wait for a XHR request
-> it :: several tests waiting for requests

But the second test will fail as current server will have been reset (it's reset here).

We could do:

describe
-> before :: set up cy.server() for before hooks
-> before :: something that needs to wait for a XHR request
-> beforeEach :: set up cy.server() for tests
-> it :: several tests waiting for requests

But then we have to set up the server twice.

Desired behavior:

Cypress should expose a way to tell cy.server() that we don't want to reset the server before each test or one way to tell that we want to preserve aliased routes.

@brian-mann
Copy link
Member

brian-mann commented Jan 11, 2018

Strongly related to this: #686

There's actually quite a bit of complexity here - not so much implementation details, but more about what a general Cypress workflow looks like and what we want users to adhere to.

@jennifer-shehane jennifer-shehane added stage: proposal 💡 No work has been done of this issue pkg/driver This is due to an issue in the packages/driver directory type: feature New feature that does not currently exist labels Jan 25, 2019
@akshayjai1
Copy link

@cypress-bot cypress-bot bot added stage: needs review The PR code is done & tested, needs review and removed stage: proposal 💡 No work has been done of this issue labels Jun 24, 2020
@cypress-bot cypress-bot bot added stage: work in progress stage: needs review The PR code is done & tested, needs review and removed stage: needs review The PR code is done & tested, needs review stage: work in progress labels Aug 25, 2020
@cypress-bot cypress-bot bot added stage: pending release and removed stage: needs review The PR code is done & tested, needs review labels Aug 31, 2020
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Sep 1, 2020

Released in 5.1.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v5.1.0, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Sep 1, 2020
@jennifer-shehane
Copy link
Member

The features requested in this issue are now possible as part of cy.route2().

cy.route2() is currently experimental and requires being enabled by passing "experimentalNetworkStubbing": true through your Cypress configuration. This will eventually be merged in as part of our standard API.

Please see the cy.route2() docs for full details: https://on.cypress.io/route2

If you encounter any issues or unexpected behavior while using cy.route2() we encourage you to open a new issue so that we can work out all the issues before public release. Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
pkg/driver This is due to an issue in the packages/driver directory type: feature New feature that does not currently exist
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants