File tree Expand file tree Collapse file tree 3 files changed +12
-22
lines changed
test/development/error-overlay Expand file tree Collapse file tree 3 files changed +12
-22
lines changed Original file line number Diff line number Diff line change 1
1
'use client'
2
2
3
- import Link from 'next/link'
4
3
import React from 'react'
5
4
6
5
export default function Page ( ) {
7
- const broken = (
8
- < >
9
- < Link href = "/invalid" as = "mailto:[email protected] " >
10
- < a > Invalid link</ a >
11
- </ Link >
12
- </ >
13
- )
14
-
15
6
const [ shouldShow , setShouldShow ] = React . useState ( false )
7
+ if ( shouldShow ) {
8
+ const error = new Error ( 'Client error!' )
9
+ ; ( error as any ) . __NEXT_ERROR_CODE = 'E40'
10
+ throw error
11
+ }
16
12
17
13
return (
18
14
< div >
19
15
< button onClick = { ( ) => setShouldShow ( true ) } > break on client</ button >
20
- { shouldShow && broken }
21
16
</ div >
22
17
)
23
18
}
Original file line number Diff line number Diff line change 1
- import { unstable_cache } from 'next/cache'
2
- import { headers } from 'next/headers'
3
- import React from 'react'
4
-
5
1
export default async function Page ( ) {
6
- const getData = unstable_cache ( async ( ) => {
7
- const h = await headers ( )
8
- return h . get ( 'x-test-header' )
9
- } , [ 'test-header-key' ] )
2
+ const error = new Error ( 'Client error!' )
3
+ ; ( error as any ) . __NEXT_ERROR_CODE = 'E40'
4
+ throw error
10
5
11
- return < div > { await getData ( ) } </ div >
6
+ return null
12
7
}
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ describe('DevErrorOverlay', () => {
14
14
15
15
const errorCode = await browser . elementByCss ( '[data-nextjs-error-code]' )
16
16
const code = await errorCode . getAttribute ( 'data-nextjs-error-code' )
17
- expect ( code ) . toBe ( 'E838 ' )
17
+ expect ( code ) . toBe ( 'E40 ' )
18
18
} )
19
19
20
20
it ( 'sends feedback when clicking helpful button' , async ( ) => {
@@ -41,7 +41,7 @@ describe('DevErrorOverlay', () => {
41
41
. textContent ( )
42
42
) . toEqual ( 'Thanks for your feedback!' )
43
43
expect ( feedbackRequests ) . toEqual ( [
44
- '/__nextjs_error_feedback?errorCode=E794 &wasHelpful=true' ,
44
+ '/__nextjs_error_feedback?errorCode=E40 &wasHelpful=true' ,
45
45
] )
46
46
} )
47
47
} )
@@ -70,7 +70,7 @@ describe('DevErrorOverlay', () => {
70
70
. textContent ( )
71
71
) . toEqual ( 'Thanks for your feedback!' )
72
72
expect ( feedbackRequests ) . toEqual ( [
73
- '/__nextjs_error_feedback?errorCode=E794 &wasHelpful=false' ,
73
+ '/__nextjs_error_feedback?errorCode=E40 &wasHelpful=false' ,
74
74
] )
75
75
} )
76
76
} )
You can’t perform that action at this time.
0 commit comments