Reputation: 18043
I want my Cypress test to fail if a XHR request is made that is not stubbed using cy.route()
, so I can be sure I have stubbed every request. This will make sure my app isn't hitting the actual server. This way if everything is stubbed, I won't require my server to be running.
Upvotes: 0
Views: 594
Reputation: 18043
Yes you can! Pass the force404
option to cy.server
:
cy.server({force404: true})
cy.route('**/user/jake', {user:{name:'Jake'})
cy.visit('/')
// your test code here
Then any XHR request to /user/jake
will work, but /user/jane
and /login
for example, will 404
Upvotes: 1