Skip to content

Commit

Permalink
test(nextjs): Fix canary tests (#12875)
Browse files Browse the repository at this point in the history
  • Loading branch information
lforst authored Jul 11, 2024
1 parent 9c613be commit 963eab7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ test('Creates a navigation transaction for app router routes', async ({ page })

const serverComponentTransactionPromise = waitForTransaction('nextjs-app-dir', async transactionEvent => {
return (
transactionEvent?.transaction === 'GET /server-component/parameter/foo/bar/baz' &&
// It seems to differ between Next.js versions whether the route is parameterized or not
(transactionEvent?.transaction === 'GET /server-component/parameter/foo/bar/baz' ||
transactionEvent?.transaction === 'GET /server-component/parameter/[...parameters]') &&
transactionEvent.contexts?.trace?.data?.['http.target'].startsWith('/server-component/parameter/foo/bar/baz') &&
(await clientNavigationTransactionPromise).contexts?.trace?.trace_id ===
transactionEvent.contexts?.trace?.trace_id
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import { waitForError, waitForTransaction } from '@sentry-internal/test-utils';

test('Sends a transaction for a request to app router', async ({ page }) => {
const serverComponentTransactionPromise = waitForTransaction('nextjs-app-dir', transactionEvent => {
return transactionEvent?.transaction === 'GET /server-component/parameter/[...parameters]';
return (
transactionEvent?.transaction === 'GET /server-component/parameter/[...parameters]' &&
transactionEvent.contexts?.trace?.data?.['http.target'].startsWith('/server-component/parameter/1337/42')
);
});

await page.goto('/server-component/parameter/1337/42');
Expand Down

0 comments on commit 963eab7

Please sign in to comment.