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.

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 issue

Current 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:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
hudsonsdadcommented, Jun 1, 2020

@jennifer-shehane - yes, this also fails when a question mark, alone, is at the end of the visited URL with a file extension.

0reactions
cypress-bot[bot]commented, Jun 23, 2020

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.

Read more comments on GitHub >

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

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