diff --git a/test/e2e/prerender.test.ts b/test/e2e/prerender.test.ts index 8be014d6f9fad..cf5bcca77d83a 100644 --- a/test/e2e/prerender.test.ts +++ b/test/e2e/prerender.test.ts @@ -1090,17 +1090,20 @@ describe('Prerender', () => { .replace('{/* */}', '') ) - await browser.waitForElementByCss('#after-change') - // we need to reload the page to trigger getStaticProps - await browser.refresh() - expect(await hasRedbox(browser)).toBe(true) - const errOverlayContent = await getRedboxHeader(browser) - - await next.patchFile(indexPage, origContent) - const errorMsg = /oops from getStaticProps/ - expect(next.cliOutput).toMatch(errorMsg) - expect(errOverlayContent).toMatch(errorMsg) + try { + await browser.waitForElementByCss('#after-change') + // we need to reload the page to trigger getStaticProps + await browser.refresh() + + expect(await hasRedbox(browser)).toBe(true) + const errOverlayContent = await getRedboxHeader(browser) + const errorMsg = /oops from getStaticProps/ + expect(next.cliOutput).toMatch(errorMsg) + expect(errOverlayContent).toMatch(errorMsg) + } finally { + await next.patchFile(indexPage, origContent) + } }) it('should always call getStaticProps without caching in dev', async () => {