cy.intercept() logs do not display as expected
See original GitHub issuedescribe("Test mocking of api requests using route2", () => {
it("Launch Website and mock meta.json api using route2", () => {
cy.fixture("meta.json").as("meta.json.mock.response");
// cy.route2("GET","**/meta.json","@meta.json.mock.response");
cy.route2(
"GET",
"**/meta.json",
`{
"loggedIn": true,
"displayName": "vivek",
"clubActive": false,
"flybuysLinked": false,
"cartItemCount": "100",
"wishlistItemCount": 1,
"messageCount": 0
}`
);
homePage.navigateToUrl("https://www.catch.com.au/");
//WHEN PAGE IS LOADED THE CART COUNT SHOULD BE = 100
});
});
So couple of issues here:
- When I supply the mock json file using alias, the mocking of “/meta.json” doesn’t happen. However when I supply the whole response body it works.
- As can be seen in the attached image, when the mocking happens by supplying the response explicitly, the time travel doesn’t indicate it as a (xhr stub)
});
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:7 (5 by maintainers)
Top Results From Across the Web
intercept - Cypress Documentation
intercept() route using cy.wait() will yield an object that contains information about the matching request/response cycle. See Using the yielded object for ...
Read more >Cypress cy.intercept Problems - Gleb Bahmutov
Cypress shows XHR calls by default in its Command Log, thus it has nothing to do with our intercept. I always thought NOT...
Read more >cy.intercept() not stubbing API in Cypress - Stack Overflow
I'm not entirely sure why it's not stubbing (presume you mean the server response is getting through?). In any case, the stubbed response ......
Read more >A Practical Guide to Intercepting Network Requests in Cypress
In this article, I'd like to walk you through some of the capabilities of Cypress' .intercept() command. It is a super useful tool,...
Read more >cy.request vs. cy.intercept - DEV Community
cy.intercept does not make a request, but rather "listens" to requests that occur on the network layer. If we "ask" Cypress to name...
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 Free
Top 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
Thanks so much @flotwig , this worked perfectly. wrt the second part, the issue is that in the time travel window if an xhr is stubbed it shows (xhr stub). However even on successfully stubbing using the solution you provided the time travel window doesn’t depict that the request has been stubbed. As you can see in the attached snapshot it simply says (xhr) for /meta.json call. It should depict (xhr stub)
Created issue to track specific implementation https://github.com/cypress-io/cypress/issues/14843