Skip to content

Instantly share code, notes, and snippets.

@paulmwatson
Created January 14, 2021 08:33
Show Gist options
  • Save paulmwatson/41c634a0382bdb7883d2c039a515bba9 to your computer and use it in GitHub Desktop.
Save paulmwatson/41c634a0382bdb7883d2c039a515bba9 to your computer and use it in GitHub Desktop.
Testing a 404 page with Cypress
cy.visit('/404')
//=> Test fails
cy.visit('/404', {failOnStatusCode: false})
//=> Test passes but does not test the HTTP code was 404
cy.request({url: '/404', failOnStatusCode: false}).its('status').should('equal', 404)
cy.visit('/404', {failOnStatusCode: false})
//=> Test passes, tests that the HTTP code was 404, and tests page was visited
@aprendible
Copy link

Thanks!

@dillingham
Copy link

Thanks!

@mpressen
Copy link

mpressen commented Apr 8, 2022

thank you !

@kenkoooo
Copy link

Thanks!

@PatFawbertMills
Copy link

Thanks Paul!

@joshuaodubanjo
Copy link

Thanks!

@CasperSchool99
Copy link

Thanks!

@AlxndrSmk
Copy link

Thank you so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment