0👍
You can mock it indeed. For example this mocks a server and a specific API-call:
cy.server()
cy.route('POST', '**/oauth/v2/token', 'fixture:/oauth/agent-token.json')
More information about route is available on the cypress site: https://docs.cypress.io/api/commands/route.html
0👍
To make sure every request is mocked, use the force404
option with 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
Source:stackexchange.com