1
1
import { nextTestSetup } from 'e2e-utils'
2
- import { assertHasRedbox , getRedboxSource , openRedbox } from 'next-test-utils'
3
2
4
3
describe ( 'hook-function-names' , ( ) => {
5
- const { next, isTurbopack } = nextTestSetup ( {
4
+ const { next } = nextTestSetup ( {
6
5
files : __dirname ,
7
6
} )
8
7
@@ -11,64 +10,41 @@ describe('hook-function-names', () => {
11
10
12
11
await browser . elementByCss ( 'button' ) . click ( )
13
12
14
- await openRedbox ( browser )
15
-
16
- if ( isTurbopack ) {
17
- expect ( await getRedboxSource ( browser ) ) . toMatchInlineSnapshot ( `
18
- "app/button/page.tsx (7:11) @ Button.useCallback[handleClick]
19
-
20
- 5 | const Button = ({ message }: { message: string }) => {
21
- 6 | const handleClick = useCallback(() => {
22
- > 7 | throw new Error(message)
23
- | ^
24
- 8 | }, [message])
25
- 9 |
26
- 10 | return ("
27
- ` )
28
- } else {
29
- expect ( await getRedboxSource ( browser ) ) . toMatchInlineSnapshot ( `
30
- "app/button/page.tsx (7:11) @ Button.useCallback[handleClick]
31
-
32
- 5 | const Button = ({ message }: { message: string }) => {
33
- 6 | const handleClick = useCallback(() => {
34
- > 7 | throw new Error(message)
35
- | ^
36
- 8 | }, [message])
37
- 9 |
38
- 10 | return ("
39
- ` )
40
- }
13
+ await expect ( browser ) . toDisplayCollapsedRedbox ( `
14
+ {
15
+ "count": 1,
16
+ "description": "Error: Kaputt!",
17
+ "environmentLabel": null,
18
+ "label": "Unhandled Runtime Error",
19
+ "source": "app/button/page.tsx (7:11) @ Button.useCallback[handleClick]
20
+ > 7 | throw new Error(message)
21
+ | ^",
22
+ "stack": [
23
+ "Button.useCallback[handleClick] app/button/page.tsx (7:11)",
24
+ "button <anonymous> (0:0)",
25
+ "Button app/button/page.tsx (11:5)",
26
+ "Page app/button/page.tsx (18:10)",
27
+ ],
28
+ }
29
+ ` )
41
30
} )
42
31
43
32
it ( 'should show readable hook names in stacks for default-exported components' , async ( ) => {
44
33
const browser = await next . browser ( '/' )
45
34
46
- await assertHasRedbox ( browser )
47
-
48
- if ( isTurbopack ) {
49
- expect ( await getRedboxSource ( browser ) ) . toMatchInlineSnapshot ( `
50
- "app/page.tsx (7:11) @ Page.useEffect
51
-
52
- 5 | export default function Page() {
53
- 6 | useEffect(() => {
54
- > 7 | throw new Error('error in useEffect')
55
- | ^
56
- 8 | }, [])
57
- 9 |
58
- 10 | return <p>Hello world!</p>"
59
- ` )
60
- } else {
61
- expect ( await getRedboxSource ( browser ) ) . toMatchInlineSnapshot ( `
62
- "app/page.tsx (7:11) @ Page.useEffect
63
-
64
- 5 | export default function Page() {
65
- 6 | useEffect(() => {
66
- > 7 | throw new Error('error in useEffect')
67
- | ^
68
- 8 | }, [])
69
- 9 |
70
- 10 | return <p>Hello world!</p>"
71
- ` )
72
- }
35
+ await expect ( browser ) . toDisplayRedbox ( `
36
+ {
37
+ "count": 1,
38
+ "description": "Error: error in useEffect",
39
+ "environmentLabel": null,
40
+ "label": "Unhandled Runtime Error",
41
+ "source": "app/page.tsx (7:11) @ Page.useEffect
42
+ > 7 | throw new Error('error in useEffect')
43
+ | ^",
44
+ "stack": [
45
+ "Page.useEffect app/page.tsx (7:11)",
46
+ ],
47
+ }
48
+ ` )
73
49
} )
74
50
} )
0 commit comments