Ajax request from previous test runs in the next test
See original GitHub issueWe have noticed a weird problem.
One of our tests has a POST request that has not finished yet, but instead runs in the next test (even before login, thus failing). I am attaching the screenshot. Notice the POST 403
to /statsbox/metadata
url - this is part of the previous successful test “scores a study …”
Also, notice that this POST happens just as the test loads the login page, thus the POST gets CSRF 403 error.
Issue Analytics
- State:
- Created 7 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
Unit Testing Ajax calls - Stack Overflow
I have an httpService module that deals with all the ajax requests (written by me). The file being tested requires the httpService module....
Read more >How to Write Unit Tests for Ajax Requests using Mocha
Prior to the test, create a fake XMLHttpRequest and arrange these requests in an array. Thus, the values that are saved in this.xhr...
Read more >Unit testing Ajax requests with Mocha - CodeUtopia
Conclusion and next steps. Ajax requests are important to test. If you verify they work correctly, the rest of your application can trust...
Read more >Chapter 13. Ajax testing - JUnit in Action, Second Edition
This chapter covers testing Ajax applications. It's a continuation of chapter 12, which discusses presentation-layer testing in general and introduces two ...
Read more >Unit testing code with utility functions & AJAX calls - Medium
I wanted to share a few tips I picked up while testing AJAX requests, in particular: when to use stubs, what to do...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hey guys, I have been encountering this issue myself, I was wondering if there was a good workaround that doesn’t rely on waiting for the xhr response, maybe running cy.visit() after each test?
I looked at the documentation, it seems this configuration proposal is not net implemented?
I look forward to your responses.
Thanks.
edit: the cy.visit() idea didn’t work.
Currently I have some AJAX requests which depends on some localStorage data. Isn’t there a way to prevent Cypress from clearing up my localStorage before each test? Or is there a workaround? I would like to control it myself.