Count number of times intercepted route was called
See original GitHub issueWhat would you like?
Intercepted routes should keep track of the number of times they were called.
I’d like to gy.get
the intercepted route and verify it was called N times.
I could put a custom property on the Req object and increment it in the RouteHandler but that is clunky, and not something the client should have to maintain. This seems to be the responsibility of the testing framework.
Why is this needed?
An essential part of testing is confirming your code is only making network requests the expected number of times. This should be baked in to the testing framework. If my code makes unnecessary requests, then my code is wrong, and I need to know about it.
SO post: https://stackoverflow.com/questions/67643208/verify-number-of-times-request-was-made
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:10 (3 by maintainers)
Top Results From Across the Web
Verify number of times request was made - cypress
Using cy.spy() as a routeHandler allows a timeout to be set on the code that checks the call count. it('counts intercepts' ...
Read more >Cypress cy.intercept Problems - Gleb Bahmutov
Count intercepts (again) #. We can count the number of times the intercept was called. 1 2
Read more >intercept - Cypress Documentation
routeMatcher is an object used to match the incoming HTTP requests with this intercepted route. All properties are optional but all those that...
Read more >A Practical Guide to Intercepting Network Requests in Cypress
intercept () can route almost any type of request, we can use it to match a network call for a static assets, e.g....
Read more >Network Requests with Cypress by Cecelia Martinez - GitNation
So this image is from a presentation called how cy.intercept works, ... function to set the count, the number of times that it's...
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
While there are clumsy work arounds, the ability to count the number of times a network request was made is fundamental to a testing library. This should be baked in to Cypress.
@pstephenwille You can do this with the
cy.get('@alias.all')
which is undocumented but I believe we’ll be documenting it soon.