I have a website that sends queries to the server using 'Apollo graphql client'.
I have set up an interface that will be displayed when this website cannot connect to the server, i.e. when it gets an error:
'Error: connect ECONNREFUSED'.
I can test this manually by shutting down the server.
I want to test with Cypress if this is working correctly.
I want to use cy.intercept() to make it look like the server is not online.
How can I do this?
I read https://docs.cypress.io/api/commands/intercept, I thought I would find a concrete example but I couldn't.
You could take a look at this thread Network automation to emulate offline mode
The gist is using two RDP calls to simulate the network going offline. As a user you would do this via the devtools. RDP gives you a programatic equivalent.
The updated example spec for Cypress 12 is here