Next.js Discord

Discord Forum

Cypress e2e testing 404 scenario

Unanswered
Nashville Warbler posted this in #help-forum
Open in Discord
Avatar
Nashville WarblerOP
How is everyone handling testing a notFound scenario with Cypress? My test was failing due to the NEXT_NOT_FOUND exception that Next throws. I ended up using a `cypress.on('uncaught:exception', (e, runnable) => { return false}).... but I feel like there must be a better way. I don't want to ingore ALL uncaught exceptions.

3 Replies

Avatar
risky
that error is how redirect works with nextjs, so i think you will have to test that it is that error for success on test
[Invoking the redirect() function throws a NEXT_REDIRECT error and terminates rendering of the route segment in which it was thrown.](https://nextjs.org/docs/app/api-reference/functions/redirect)
Avatar
Nashville WarblerOP
ok thank you