From 3f75da027aed8f33236e0fef7984d0f906a87160 Mon Sep 17 00:00:00 2001 From: Walmyr Date: Thu, 18 Jan 2024 23:55:34 +0100 Subject: [PATCH] Add more info to the cy.intercept section --- src/index.html | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/index.html b/src/index.html index f043e48..ab5f1e1 100644 --- a/src/index.html +++ b/src/index.html @@ -153,6 +153,12 @@

For example: cy.wait('@getTodo').its('response.statusCode').should('be.equal', 500).

And maybe, even assert that certain fallback element has been displayed.

For example: cy.contains('.error', 'Oops, something went wrong.').should('be.visible').

+

Finally, with the cy.intercept()command, you could force a network error, to test how your web app would behave if there were no internet available, for instance.

+

For example: cy.intercept('GET', 'https://api.example.com/todos/1', { forceNetworkError: true }).as('getTodo').

+

Then, you could wait for such a failure.

+

For example: cy.wait('@getTodo').

+

And then, you could even assert that certain fallback element has been displayed.

+

For example: cy.contains('.error', "Oops, it seems you don't have internet connection.").should('be.visible').