Skip to content

Commit

Permalink
test(nextjs): Migrate app directory tests to Playwright. (#6896)
Browse files Browse the repository at this point in the history
  • Loading branch information
onurtemizkan authored Jan 23, 2023
1 parent 1855705 commit 3696504
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 46 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { getMultipleSentryEnvelopeRequests, countEnvelopes } from './utils/helpers';
import { test, expect } from '@playwright/test';

test('should create a pageload transaction when the `app` directory is used with a client component.', async ({
page,
}) => {
if (Number(process.env.NEXTJS_VERSION) < 13 || Number(process.env.NODE_MAJOR) < 16) {
// Next.js versions < 13 don't support the app directory and the app dir requires Node v16.8.0 or later.
return;
}

const [transaction] = await getMultipleSentryEnvelopeRequests(page, 1, {
url: '/clientcomponent',
envelopeType: 'transaction',
});

expect(transaction).toMatchObject({
contexts: {
trace: {
op: 'pageload',
},
},
transaction: '/clientcomponent',
});

expect(await countEnvelopes(page, { url: '/clientcomponent', envelopeType: 'transaction', timeout: 2000 })).toBe(1);
});

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { getMultipleSentryEnvelopeRequests, countEnvelopes } from './utils/helpers';
import { test, expect } from '@playwright/test';

test('should create a pageload transaction when the `app` directory is used with a server component.', async ({
page,
}) => {
if (Number(process.env.NEXTJS_VERSION) < 13 || Number(process.env.NODE_MAJOR) < 16) {
// Next.js versions < 13 don't support the app directory and the app dir requires Node v16.8.0 or later.
return;
}

const [transaction] = await getMultipleSentryEnvelopeRequests(page, 1, {
url: '/servercomponent',
envelopeType: 'transaction',
});

expect(transaction).toMatchObject({
contexts: {
trace: {
op: 'pageload',
},
},
transaction: '/servercomponent',
});

expect(await countEnvelopes(page, { url: '/servercomponent', envelopeType: 'transaction', timeout: 2000 })).toBe(1);
});

0 comments on commit 3696504

Please sign in to comment.