Created
January 31, 2023 09:59
-
-
Save NoriSte/2d2c43e3d3ea4905fc8fc6c02188bd33 to your computer and use it in GitHub Desktop.
Preventing requests to hit the server during server-free Cypress tests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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