Skip to content

Commit 7624607

Browse files
committed
Add integration test
1 parent 1f398ae commit 7624607

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default function ({ children }: { children: React.ReactNode }) {
2+
return <>{children}</>;
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
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 numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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+
});

0 commit comments

Comments
 (0)