Skip to content

Commit 6eba0ed

Browse files
committed
Fix faulty test
1 parent 7ac3612 commit 6eba0ed

File tree

1 file changed

+35
-19
lines changed

1 file changed

+35
-19
lines changed

test/development/app-dir/owner-stack/owner-stack.test.ts

Lines changed: 35 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
/* eslint-disable jest/no-standalone-expect */
21
import { nextTestSetup } from 'e2e-utils'
3-
import { assertNoRedbox } from 'next-test-utils'
2+
import { assertNoRedbox, retry } from 'next-test-utils'
43

54
// Remove the location `()` part in every line of stack trace;
65
// Remove the leading spaces in every line of stack trace;
@@ -22,21 +21,39 @@ describe('app-dir - owner-stack', () => {
2221
files: __dirname,
2322
})
2423

25-
// Webpack will trigger "[Fast Refresh] performing full reload because your application had an unrecoverable error" in CI.
26-
// Repros locally on first visit.
27-
;(isTurbopack ? it : it.skip)(
28-
'should log stitched error for browser uncaught errors',
29-
async () => {
30-
let errorStack: string | undefined
31-
const browser = await next.browser('/browser/uncaught', {
32-
beforePageLoad: (page) => {
33-
page.on('pageerror', (error: unknown) => {
34-
errorStack = (error as any).stack
35-
})
24+
it('should log stitched error for browser uncaught errors', async () => {
25+
let errorStack: string | undefined
26+
const browser = await next.browser('/browser/uncaught', {
27+
beforePageLoad: (page) => {
28+
page.on('pageerror', (error: unknown) => {
29+
errorStack = (error as any).stack
30+
})
31+
},
32+
})
33+
34+
if (!isTurbopack) {
35+
// Wait for Redbox to settle.
36+
// TODO: Don't reload when landing on a faulty page.
37+
// The issue may be that we receive an HMR update at all on landing.
38+
// This is flaky. Sometimes we miss that the reload happened.
39+
await retry(
40+
async () => {
41+
const logs = await browser.log()
42+
expect(logs).toEqual(
43+
expect.arrayContaining([
44+
expect.objectContaining({
45+
message:
46+
'[Fast Refresh] performing full reload because your application had an unrecoverable error',
47+
}),
48+
])
49+
)
3650
},
37-
})
51+
1000,
52+
200
53+
).catch(() => {})
54+
}
3855

39-
await expect(browser).toDisplayRedbox(`
56+
await expect(browser).toDisplayRedbox(`
4057
{
4158
"count": 1,
4259
"description": "Error: browser error",
@@ -53,16 +70,15 @@ describe('app-dir - owner-stack', () => {
5370
}
5471
`)
5572

56-
expect(normalizeBrowserConsoleStackTrace(errorStack))
57-
.toMatchInlineSnapshot(`
73+
expect(normalizeBrowserConsoleStackTrace(errorStack))
74+
.toMatchInlineSnapshot(`
5875
"Error: browser error
5976
at useThrowError
6077
at useErrorHook
6178
at Page
6279
at ClientPageRoot"
6380
`)
64-
}
65-
)
81+
})
6682

6783
it('should log stitched error for browser caught errors', async () => {
6884
const browser = await next.browser('/browser/caught')

0 commit comments

Comments
 (0)