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')
Watch video Test 404 Page online, duration hours minute second in high quality that is uploaded to the channel gleb bahmutov 05 January 2022. Share the link to the video on social media so that your subscribers and friends will also watch this video. This video clip has been viewed 1,398 times and liked it 20 visitors.