cy.wait() does not resolve when the XHR contains static resource-like text in the XHR's query params or hash (like `.js`, `.html`, `.css`)
See original GitHub issueCurrent behavior:
Discovered this while trying to test for ad requests for my employer. When a URL with file extension, like .html, and a question mark (for a query string parameter) is visited, the request that is listened for is no longer detected. Remove the question mark, and the request is detected.
Desired behavior:
Before promoting a build in production, we test the build using a query-string parameter, so the wish is for this to work when a query-string parameter is present in the visited URL.
Test code to reproduce
describe("Oregon Live Ads", () => {
it("test cy.route()", () => {
cy.viewport(1500, 1024);
Cypress.on('uncaught:exception', () => {
return false;
});
cy.server();
cy.route({
url: /gampad\/ads\?/,
}).as("waitForAd");
cy.visit(
"https://www.oregonlive.com/news/2019/12/vaping-related-lung-illness-epidemic-has-likely-peaked-feds-say.html"
, {qs: {answer: "42"}} // When this is commented out, the test passes.
);
cy.wait("@waitForAd").then((req) => {
expect(true).to.equal(true);
});
});
});
Versions
Cypress Version: Cypress 4.2.0 OS: MacOS Catalina 10.15.2 Browser: Default Chrome browser that is built into Cypress
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:10 (3 by maintainers)
Top Results From Across the Web
Failing to pass the test of XHR request using Cypress
The request must be initiated after the cy.route() and before the cy.wait(). It works like this: it.only("Waiting for server response", ...
Read more >Changelog - Cypress Documentation
cy.wait() now correctly resolves when waiting for XHR requests that contain resource-like text in the XHR's query params or hash (like .js ,...
Read more >JavaScript Tutorial - from callbacks to async/await - Morioh
Using the callback to solve our problem allows us to do something like this to the ... A promise is initialized with a...
Read more >Diff - refs/heads/master^! - external/trace-viewer - Git at Google
Do not print unused suppressions so that above message is clearly - # visible and ... and - - (d) If the Work...
Read more >html-media: changeset 92:1e6898152c5b
<p> + + </p><p> Publication as an Editor's Draft does not imply endorsement ... class="">If the JavaScript code fetching media data has problems...
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
@jennifer-shehane - yes, this also fails when a question mark, alone, is at the end of the visited URL with a file extension.
Released in
4.9.0
.This comment thread has been locked. If you are still experiencing this issue after upgrading to Cypress v4.9.0, please open a new issue.