-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(nextjs): Trace errors in page components
- Loading branch information
Showing
2 changed files
with
86 additions
and
36 deletions.
There are no files selected for viewing
28 changes: 21 additions & 7 deletions
28
packages/e2e-tests/test-applications/nextjs-app-dir/tests/pages-ssr-errors.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,38 @@ | ||
import { test, expect } from '@playwright/test'; | ||
import { waitForError } from '../event-proxy-server'; | ||
import { waitForError, waitForTransaction } from '../event-proxy-server'; | ||
|
||
test('Will capture error for SSR rendering error (Class Component)', async ({ page }) => { | ||
test('Will capture error for SSR rendering error with a connected trace (Class Component)', async ({ page }) => { | ||
const errorEventPromise = waitForError('nextjs-13-app-dir', errorEvent => { | ||
return errorEvent?.exception?.values?.[0]?.value === 'Pages SSR Error Class'; | ||
}); | ||
|
||
const serverComponentTransaction = waitForTransaction('nextjs-13-app-dir', async transactionEvent => { | ||
return ( | ||
transactionEvent?.transaction === '/pages-router/ssr-error-class' && | ||
(await errorEventPromise).contexts?.trace?.trace_id === transactionEvent.contexts?.trace?.trace_id | ||
); | ||
}); | ||
|
||
await page.goto('/pages-router/ssr-error-class'); | ||
|
||
const errorEvent = await errorEventPromise; | ||
expect(errorEvent).toBeDefined(); | ||
expect(await errorEventPromise).toBeDefined(); | ||
expect(await serverComponentTransaction).toBeDefined(); | ||
}); | ||
|
||
test('Will capture error for SSR rendering error (Functional Component)', async ({ page }) => { | ||
test('Will capture error for SSR rendering error with a connected trace (Functional Component)', async ({ page }) => { | ||
const errorEventPromise = waitForError('nextjs-13-app-dir', errorEvent => { | ||
return errorEvent?.exception?.values?.[0]?.value === 'Pages SSR Error FC'; | ||
}); | ||
|
||
const serverComponentTransaction = waitForTransaction('nextjs-13-app-dir', async transactionEvent => { | ||
return ( | ||
transactionEvent?.transaction === '/pages-router/ssr-error-class' && | ||
(await errorEventPromise).contexts?.trace?.trace_id === transactionEvent.contexts?.trace?.trace_id | ||
); | ||
}); | ||
|
||
await page.goto('/pages-router/ssr-error-fc'); | ||
|
||
const errorEvent = await errorEventPromise; | ||
expect(errorEvent).toBeDefined(); | ||
expect(await errorEventPromise).toBeDefined(); | ||
expect(await serverComponentTransaction).toBeDefined(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters