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

Stubbed XHR that are triggered between 2 tests are not stubbed #538

Closed
eprevot opened this issue Jun 16, 2017 · 2 comments
Closed

Stubbed XHR that are triggered between 2 tests are not stubbed #538

eprevot opened this issue Jun 16, 2017 · 2 comments

Comments

@eprevot
Copy link

eprevot commented Jun 16, 2017

Current behavior:

  • In test 1, I stub some routes
  • In test 1, I cy.visit() my application that triggers some XHR (some stubbed and some not stubbed), I check what I need and I don't wait for all XHR to end
  • In test 2, I cy.visit() my application, the page is reloaded but it randomly happens that some requests triggered by the previous test "bleed" in this test

My problem : the XHR that are stubbed in test 1, are not stubbed when bleeding in test 2

Expected behavior:

Either XHR requests should not bleed in next test or at least they should remain stubbed

Additional Info (images, notes, stack traces, etc)

When requests are bleeding in another test, it looks like this (test block appears before before each block) :
capture d ecran 2017-06-15 a 18 37 33

Bleeding requests usually are not a problem, since I cy.visit() at the beginning of each test, they don't interfere with the test. But some XHR should not reach my server on CI environment, that's why I stub them. When they reach the server on CI, they cause an error 500, and we configured our CI to make the build fail when there is any error on server. That's why I need them to stay stubbed.

From what I understood of our discussion on gitter with @brian-mann :

  • it could be a race condition where the XHR is created post teardown, after cypress unrolls all the stubs, but before the page is unloaded (before next cy.visit)
  • cypress should remove the application entirely before running the end of test teardown (that would prevent any javascript from running, execution would end), then unroll things and prepare for the next test
  • enforcing teardown won't work for users that don't cy.visit between each test
  • cypress should not teardown the app IF its the last test, so you can visually inspect it post test
  • Operating System: Mac OS 10.11
  • Cypress Version: 0.19.2
  • Browser/Browser Version: Chrome 59
@brian-mann
Copy link
Member

This is documented in detail here: #686

@jennifer-shehane jennifer-shehane added the stage: ready for work The issue is reproducible and in scope label Feb 1, 2019
@jennifer-shehane
Copy link
Member

Unfortunately we have to close this issue due to inactivity. Please comment if there is new information to provide concerning the original issue and we can reopen.

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

No branches or pull requests

3 participants