File tree 3 files changed +37
-0
lines changed
packages/nextjs/test/integration
app/throwing-servercomponent
3 files changed +37
-0
lines changed Original file line number Diff line number Diff line change
1
+ export default function ( { children } : { children : React . ReactNode } ) {
2
+ return < > { children } </ > ;
3
+ }
Original file line number Diff line number Diff line change
1
+ export default async function ( ) {
2
+ // do some request so that next will render this component serverside for each new pageload
3
+ await fetch ( 'http://example.com' , { cache : 'no-store' } ) ;
4
+ throw new Error ( 'I am an Error thrown inside a server component' ) ;
5
+ return < p > I am a server component!</ p > ;
6
+ }
Original file line number Diff line number Diff line change
1
+ import { NextTestEnv } from './utils/helpers' ;
2
+
3
+ describe ( 'Loading the throwing server component' , ( ) => {
4
+ it ( 'should capture an error event via auto wrapping' , async ( ) => {
5
+ if ( process . env . USE_APPDIR !== 'true' ) {
6
+ return ;
7
+ }
8
+
9
+ const env = await NextTestEnv . init ( ) ;
10
+ const url = `${ env . url } /throwing-servercomponent` ;
11
+
12
+ const envelope = await env . getEnvelopeRequest ( {
13
+ url,
14
+ envelopeType : 'event' ,
15
+ } ) ;
16
+
17
+ expect ( envelope [ 2 ] ) . toMatchObject ( {
18
+ exception : {
19
+ values : [
20
+ {
21
+ type : 'Error' ,
22
+ value : 'I am an Error thrown inside a server component' ,
23
+ } ,
24
+ ] ,
25
+ } ,
26
+ } ) ;
27
+ } ) ;
28
+ } ) ;
You can’t perform that action at this time.
0 commit comments