cy.route doesn't match http calls to .js resources
See original GitHub issueCurrent behavior:
(Notice how # is - because cypress doesn’t think the route is matched)
Interestingly the response handler is still called and the log appears in the console.
Desired behavior:
I’d like the route to match and be able to replace the contents of the resource I’m trying to hijack.
Steps to reproduce:
describe('Route matching fails', function () {
it('fail matching routes', function () {
cy.server()
cy.route({
method: 'GET',
url: 'https://consent.snmmd.nl/js/cookiebar-latest.js',
response: (req) => {
console.log('[REQUEST] JavaScript');
}
})
cy.visit('http://www.nu.nl')
})
})
Versions
Cypress 2.1.0 macOS 10.12.6 Node 10.0.0
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Cypress doesn't match the newest route stub when url ...
Current behavior: When having multiple routes with paths that match a request, the newest one assigned does not match and a different stub ......
Read more >Is there a way to assert that a route has not been called in ...
I am currently working around this by asserting that the successful request toast message is not being displayed but it is a flimsy...
Read more >Cypress cy.intercept Problems - Gleb Bahmutov
The command cy.intercept can match requests using a substring, a minimatch, or a regular expression. By default, it intercepts requests ...
Read more >intercept - Cypress Documentation
Match the route to a specific HTTP method ( GET , POST , PUT , etc). If no method is defined Cypress will...
Read more >Stubbing and Mocking Network Request with Cypress new ...
We will also see what difference it makes with cy. route () vs cy.intercept() commands This video is part of the course: ...
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
Have been thinking about this some. I thought maybe some people would find it useful to hook into the
onLoad
event and edit the<head>
directly, maybe edit the JS resources here.cy.route() and cy.server() are now deprecated. We suggest migrating to cy.intercept(). Open a new issue if you encounter one with intercepting calls to .js resources using cy.intercept().