question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ajax request from previous test runs in the next test

See original GitHub issue

We 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.

screen shot 2016-09-08 at 8 51 57 am

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
dipunmcommented, Jan 22, 2018

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.

1reaction
romelperezcommented, Aug 26, 2017

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found