Skip to content

Instantly share code, notes, and snippets.

@NoriSte
Created January 31, 2023 09:59
Show Gist options
  • Save NoriSte/2d2c43e3d3ea4905fc8fc6c02188bd33 to your computer and use it in GitHub Desktop.
Save NoriSte/2d2c43e3d3ea4905fc8fc6c02188bd33 to your computer and use it in GitHub Desktop.
Preventing requests to hit the server during server-free Cypress tests
/**
* Ensure no requests hit the server, it's mostly a safe protection for the developers running
* server-free tests that could miss some requests are actually hitting the real server, then
* resulting in test flakiness because of partial server stubbing.
*/
export function blockServerRequests() {
cy.log('**--- Prevent any requests to hit the real server**');
cy.intercept('http://localhost:8080/**', { forceNetworkError: true });
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment