Skip to content

Commit 29e6ff9

Browse files
committed
test(nextjs): Migrate appDir tests to Playwright.
1 parent 8998fde commit 29e6ff9

File tree

4 files changed

+56
-46
lines changed

4 files changed

+56
-46
lines changed

packages/nextjs/test/integration/test/client/appDirTracingPageloadClientcomponent.js

Lines changed: 0 additions & 23 deletions
This file was deleted.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { getMultipleSentryEnvelopeRequests, countEnvelopes } from './utils/helpers';
2+
import { test, expect } from '@playwright/test';
3+
4+
test('should create a pageload transaction when the `app` directory is used with a client component.', async ({
5+
page,
6+
}) => {
7+
if (Number(process.env.NEXTJS_VERSION) < 13 || Number(process.env.NODE_MAJOR) < 16) {
8+
// Next.js versions < 13 don't support the app directory and the app dir requires Node v16.8.0 or later.
9+
return;
10+
}
11+
12+
const [transaction] = await getMultipleSentryEnvelopeRequests(page, 1, {
13+
url: '/clientcomponent',
14+
envelopeType: 'transaction',
15+
});
16+
17+
expect(transaction).toMatchObject({
18+
contexts: {
19+
trace: {
20+
op: 'pageload',
21+
},
22+
},
23+
transaction: '/clientcomponent',
24+
});
25+
26+
expect(await countEnvelopes(page, { url: '/clientcomponent', envelopeType: 'transaction' })).toBe(1);
27+
});

packages/nextjs/test/integration/test/client/appDirTracingPageloadServercomponent.js

Lines changed: 0 additions & 23 deletions
This file was deleted.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { getMultipleSentryEnvelopeRequests, countEnvelopes } from './utils/helpers';
2+
import { test, expect } from '@playwright/test';
3+
4+
test('should create a pageload transaction when the `app` directory is used with a server component.', async ({
5+
page,
6+
}) => {
7+
if (Number(process.env.NEXTJS_VERSION) < 13 || Number(process.env.NODE_MAJOR) < 16) {
8+
// Next.js versions < 13 don't support the app directory and the app dir requires Node v16.8.0 or later.
9+
return;
10+
}
11+
12+
const [transaction] = await getMultipleSentryEnvelopeRequests(page, 1, {
13+
url: '/servercomponent',
14+
envelopeType: 'transaction',
15+
});
16+
17+
console.log('TRANSACTION', transaction);
18+
19+
expect(transaction).toMatchObject({
20+
contexts: {
21+
trace: {
22+
op: 'pageload',
23+
},
24+
},
25+
transaction: '/servercomponent',
26+
});
27+
28+
expect(await countEnvelopes(page, { url: '/servercomponent', envelopeType: 'transaction' })).toBe(1);
29+
});

0 commit comments

Comments
 (0)