In this video, I show how to use cy.visit and cy.request commands to verify the server is returning a 404 page for invalid resource URLs. Find the full source code in https://github.com/bahmutov/cypress-c... In summary, I did:
const url = '/does-not-exist'
cy.request({ url, failOnStatusCode: false })
.its('status', { timeout: 0 })
.should('equal', 404)
cy.visit(url, { failOnStatusCode: false })
cy.contains('span', '404')
On this page of the site you can watch the video online Test 404 Page with a duration of hours minute second in good quality, which was uploaded by the user gleb bahmutov 05 January 2022, share the link with friends and acquaintances, this video has already been watched 1,398 times on youtube and it was liked by 20 viewers. Enjoy your viewing!