Skip to content

Commit 1320f2d

Browse files
authored
test(nextjs): Remove Next.js integration tests (#13155)
1 parent 26c81e8 commit 1320f2d

File tree

111 files changed

+16
-2573
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+16
-2573
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -595,56 +595,6 @@ jobs:
595595
- name: Unit Test
596596
run: yarn lerna run test --scope @sentry/profiling-node
597597

598-
job_nextjs_integration_test:
599-
name: Nextjs (Node ${{ matrix.node }}) Tests
600-
needs: [job_get_metadata, job_build]
601-
if: needs.job_get_metadata.outputs.changed_nextjs == 'true' || github.event_name != 'pull_request'
602-
timeout-minutes: 25
603-
runs-on: ubuntu-20.04
604-
strategy:
605-
fail-fast: false
606-
matrix:
607-
node: [14, 16, 18, 20, 22]
608-
steps:
609-
- name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }})
610-
uses: actions/checkout@v4
611-
with:
612-
ref: ${{ env.HEAD_COMMIT }}
613-
- name: Set up Node
614-
uses: actions/setup-node@v4
615-
with:
616-
node-version: ${{ matrix.node }}
617-
- name: Restore caches
618-
uses: ./.github/actions/restore-cache
619-
env:
620-
DEPENDENCY_CACHE_KEY: ${{ needs.job_build.outputs.dependency_cache_key }}
621-
- name: Get npm cache directory
622-
id: npm-cache-dir
623-
run: echo "dir=$(npm config get cache)" >> $GITHUB_OUTPUT
624-
- name: Get Playwright version
625-
id: playwright-version
626-
run: echo "version=$(node -p "require('@playwright/test/package.json').version")" >> $GITHUB_OUTPUT
627-
- uses: actions/cache@v4
628-
name: Check if Playwright browser is cached
629-
id: playwright-cache
630-
with:
631-
path: ${{ steps.npm-cache-dir.outputs.dir }}
632-
key: ${{ runner.os }}-Playwright-${{steps.playwright-version.outputs.version}}
633-
- name: Install Playwright browser if not cached
634-
if: steps.playwright-cache.outputs.cache-hit != 'true'
635-
run: npx playwright install --with-deps
636-
env:
637-
PLAYWRIGHT_BROWSERS_PATH: ${{steps.npm-cache-dir.outputs.dir}}
638-
- name: Install OS dependencies of Playwright if cache hit
639-
if: steps.playwright-cache.outputs.cache-hit == 'true'
640-
run: npx playwright install-deps
641-
- name: Run tests
642-
env:
643-
NODE_VERSION: ${{ matrix.node }}
644-
run: |
645-
cd packages/nextjs
646-
yarn test:integration
647-
648598
job_browser_playwright_tests:
649599
name: Playwright (${{ matrix.bundle }}${{ matrix.shard && format(' {0}/{1}', matrix.shard, matrix.shards) || ''}}) Tests
650600
needs: [job_get_metadata, job_build]
@@ -1328,7 +1278,6 @@ jobs:
13281278
job_deno_unit_tests,
13291279
job_node_unit_tests,
13301280
job_profiling_node_unit_tests,
1331-
job_nextjs_integration_test,
13321281
job_node_integration_tests,
13331282
job_browser_playwright_tests,
13341283
job_browser_loader_tests,

dev-packages/e2e-tests/test-applications/nextjs-13/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,17 @@
2424
},
2525
"devDependencies": {
2626
"@playwright/test": "^1.44.1",
27-
"@sentry-internal/test-utils": "link:../../../test-utils",
27+
"@sentry-internal/browser-utils": "latest || *",
2828
"@sentry-internal/feedback": "latest || *",
29+
"@sentry-internal/replay": "latest || *",
2930
"@sentry-internal/replay-canvas": "latest || *",
30-
"@sentry-internal/browser-utils": "latest || *",
31+
"@sentry-internal/test-utils": "link:../../../test-utils",
3132
"@sentry/browser": "latest || *",
3233
"@sentry/core": "latest || *",
3334
"@sentry/nextjs": "latest || *",
3435
"@sentry/node": "latest || *",
3536
"@sentry/opentelemetry": "latest || *",
3637
"@sentry/react": "latest || *",
37-
"@sentry-internal/replay": "latest || *",
3838
"@sentry/types": "latest || *",
3939
"@sentry/utils": "latest || *",
4040
"@sentry/vercel-edge": "latest || *"
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import { NextApiRequest, NextApiResponse } from 'next';
22

3-
const handler = async (_req: NextApiRequest, res: NextApiResponse): Promise<void> => {
3+
export default async (_req: NextApiRequest, res: NextApiResponse): Promise<void> => {
44
res.status(200).json({ success: true });
55
};
6-
7-
module.exports = handler;
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import { NextApiRequest, NextApiResponse } from 'next';
22

3-
const handler = async (_req: NextApiRequest, res: NextApiResponse): Promise<void> => {
3+
export default async (_req: NextApiRequest, res: NextApiResponse): Promise<void> => {
44
res.status(200).json({ success: true });
55
};
6-
7-
module.exports = handler;

dev-packages/e2e-tests/test-applications/nextjs-13/tests/server/cjs-api-endpoints.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
import { expect, test } from '@playwright/test';
22
import { waitForTransaction } from '@sentry-internal/test-utils';
33

4+
const packageJson = require('../../package.json');
5+
const nextjsVersion = packageJson.dependencies.next;
6+
const nextjsMajor = Number(nextjsVersion.split('.')[0]);
7+
48
test('should create a transaction for a CJS pages router API endpoint', async ({ request }) => {
9+
test.skip(nextjsMajor > 13, 'Next.js does not like CJS routes after a certain point.');
10+
511
const transactionPromise = waitForTransaction('nextjs-13', async transactionEvent => {
612
return (
713
transactionEvent.transaction === 'GET /api/cjs-api-endpoint' &&
@@ -62,6 +68,8 @@ test('should create a transaction for a CJS pages router API endpoint', async ({
6268
});
6369

6470
test('should not mess up require statements in CJS API endpoints', async ({ request }) => {
71+
test.skip(nextjsMajor > 13, 'Next.js does not like CJS routes after a certain point.');
72+
6573
const transactionPromise = waitForTransaction('nextjs-13', async transactionEvent => {
6674
return (
6775
transactionEvent.transaction === 'GET /api/cjs-api-endpoint-with-require' &&

dev-packages/e2e-tests/test-applications/nextjs-13/tests/server/excluded-api-endpoints.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ test('should not automatically create transactions for routes that were excluded
1111
);
1212
});
1313

14-
await (await request.get(`/api/endpoint-excluded-with-string`)).json();
14+
expect(await (await request.get(`/api/endpoint-excluded-with-string`)).text()).toBe('{"success":true}');
1515

1616
let transactionPromiseReceived = false;
1717
transactionPromise.then(() => {
@@ -33,7 +33,7 @@ test('should not automatically create transactions for routes that were excluded
3333
);
3434
});
3535

36-
await (await request.get(`/api/endpoint-excluded-with-regex`)).json();
36+
expect(await (await request.get(`/api/endpoint-excluded-with-regex`)).text()).toBe('{"success":true}');
3737

3838
let transactionPromiseReceived = false;
3939
transactionPromise.then(() => {

dev-packages/e2e-tests/test-applications/nextjs-13/tests/server/server-component-error.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ test('Should capture an error thrown in a server component', async ({ page }) =>
1212
contexts: {
1313
runtime: { name: 'node', version: expect.any(String) },
1414
trace: {
15-
parent_span_id: expect.any(String),
1615
span_id: expect.any(String),
1716
trace_id: expect.any(String),
1817
},
@@ -27,7 +26,6 @@ test('Should capture an error thrown in a server component', async ({ page }) =>
2726
},
2827
],
2928
},
30-
modules: { next: '13.2.0' },
3129
platform: 'node',
3230
request: {
3331
cookies: expect.any(Object),

dev-packages/e2e-tests/test-applications/nextjs-13/tests/server/wrapApiHandlerWithSentry.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ const cases = [
2222
cases.forEach(({ name, url, transactionName }) => {
2323
test(`Should capture transactions for routes with various shapes (${name})`, async ({ request }) => {
2424
const transactionEventPromise = waitForTransaction('nextjs-13', transactionEvent => {
25-
console.log({ t: transactionEvent.transaction });
2625
return transactionEvent.transaction === transactionName && transactionEvent.contexts?.trace?.op === 'http.server';
2726
});
2827

packages/nextjs/.eslintrc.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ module.exports = {
66
parserOptions: {
77
jsx: true,
88
},
9-
ignorePatterns: ['test/integration/**', 'playwright.config.ts'],
109
extends: ['../../.eslintrc.js'],
1110
rules: {
1211
'@sentry-internal/sdk/no-optional-chaining': 'off',

packages/nextjs/jest.config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@ const baseConfig = require('../../jest/jest.config.js');
22

33
module.exports = {
44
...baseConfig,
5-
testPathIgnorePatterns: ['<rootDir>/test/integration/'],
65
};

packages/nextjs/package.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,8 @@
115115
"fix": "eslint . --format stylish --fix",
116116
"lint": "eslint . --format stylish",
117117
"test": "yarn test:unit",
118-
"test:all": "run-s test:unit test:integration",
118+
"test:all": "run-s test:unit",
119119
"test:unit": "jest",
120-
"test:integration": "./test/run-integration-tests.sh && yarn test:types",
121-
"test:integration:clean": "(cd test/integration && rimraf .cache node_modules build)",
122-
"test:integration:client": "yarn playwright test test/integration/test/client/",
123-
"test:integration:server": "(cd test/integration && yarn test:server)",
124120
"test:types": "cd test/types && yarn test",
125121
"test:watch": "jest --watch",
126122
"vercel:branch": "source vercel/set-up-branch-for-test-app-use.sh",

packages/nextjs/playwright.config.ts

Lines changed: 0 additions & 23 deletions
This file was deleted.

packages/nextjs/test/integration/.gitignore

Lines changed: 0 additions & 39 deletions
This file was deleted.

packages/nextjs/test/integration/app/clientcomponent/layout.tsx

Lines changed: 0 additions & 3 deletions
This file was deleted.

packages/nextjs/test/integration/app/clientcomponent/page.tsx

Lines changed: 0 additions & 5 deletions
This file was deleted.

packages/nextjs/test/integration/app/layout.tsx

Lines changed: 0 additions & 7 deletions
This file was deleted.

packages/nextjs/test/integration/app/servercomponent/layout.tsx

Lines changed: 0 additions & 3 deletions
This file was deleted.

packages/nextjs/test/integration/app/servercomponent/page.tsx

Lines changed: 0 additions & 8 deletions
This file was deleted.

packages/nextjs/test/integration/components/Layout.tsx

Lines changed: 0 additions & 44 deletions
This file was deleted.

packages/nextjs/test/integration/components/List.tsx

Lines changed: 0 additions & 20 deletions
This file was deleted.

packages/nextjs/test/integration/components/ListDetail.tsx

Lines changed: 0 additions & 17 deletions
This file was deleted.

packages/nextjs/test/integration/components/ListItem.tsx

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)