https://cypress.io logo
Imitate ERR_CONNECTION_REFUSED with cy.intersept o...
# i-need-help
c
need to check how website behaves with backend down
m
This is an example how to kill a backend call
Copy code
js

// dynamically destroy the request and
// respond with a network error
cy.intercept('POST', '/users', (req) => {
  if (mustDestroy(req)) {
    req.destroy()
  }

  function mustDestroy(req) {
    // code that determines whether to force a network error
    // based on the contents of `req`
  }
})