Fairly new to Cypress and it's been smooth sailing so far until I wanted to fake out a network request. Code is like this:
describe('Some test', function(){
it('Can fake out an XHR response', function(){
cy.server()
cy.route('https://reqres.in/api/users', [{ id: 1, name: 'Pat' }]).as('getMessages')
cy.request('https://reqres.in/api/users')
cy.wait(['@getMessages'])
...
No matter what I try I get:
CypressError: Timed out retrying: cy.wait() timed out waiting 5000ms for the 1st request to the route: 'getMessages'. No request ever occurred.
What am I doing wrong here?
EDIT: I changed the code to this:
cy.server()
cy.route('https://reqres.in/api/users', [{ id: 1, name: 'Pat' }]).as('getMessages')
cy.request('https://reqres.in/api/users')
cy.wait(['@getMessages'])
But the result was as below:
