Skip to content

test(nextjs): Remove Next.js integration tests #13155

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 0 additions & 51 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -595,56 +595,6 @@ jobs:
- name: Unit Test
run: yarn lerna run test --scope @sentry/profiling-node

job_nextjs_integration_test:
name: Nextjs (Node ${{ matrix.node }}) Tests
needs: [job_get_metadata, job_build]
if: needs.job_get_metadata.outputs.changed_nextjs == 'true' || github.event_name != 'pull_request'
timeout-minutes: 25
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
node: [14, 16, 18, 20, 22]
steps:
- name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }})
uses: actions/checkout@v4
with:
ref: ${{ env.HEAD_COMMIT }}
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- name: Restore caches
uses: ./.github/actions/restore-cache
env:
DEPENDENCY_CACHE_KEY: ${{ needs.job_build.outputs.dependency_cache_key }}
- name: Get npm cache directory
id: npm-cache-dir
run: echo "dir=$(npm config get cache)" >> $GITHUB_OUTPUT
- name: Get Playwright version
id: playwright-version
run: echo "version=$(node -p "require('@playwright/test/package.json').version")" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
name: Check if Playwright browser is cached
id: playwright-cache
with:
path: ${{ steps.npm-cache-dir.outputs.dir }}
key: ${{ runner.os }}-Playwright-${{steps.playwright-version.outputs.version}}
- name: Install Playwright browser if not cached
if: steps.playwright-cache.outputs.cache-hit != 'true'
run: npx playwright install --with-deps
env:
PLAYWRIGHT_BROWSERS_PATH: ${{steps.npm-cache-dir.outputs.dir}}
- name: Install OS dependencies of Playwright if cache hit
if: steps.playwright-cache.outputs.cache-hit == 'true'
run: npx playwright install-deps
- name: Run tests
env:
NODE_VERSION: ${{ matrix.node }}
run: |
cd packages/nextjs
yarn test:integration

job_browser_playwright_tests:
name: Playwright (${{ matrix.bundle }}${{ matrix.shard && format(' {0}/{1}', matrix.shard, matrix.shards) || ''}}) Tests
needs: [job_get_metadata, job_build]
Expand Down Expand Up @@ -1328,7 +1278,6 @@ jobs:
job_deno_unit_tests,
job_node_unit_tests,
job_profiling_node_unit_tests,
job_nextjs_integration_test,
job_node_integration_tests,
job_browser_playwright_tests,
job_browser_loader_tests,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@
},
"devDependencies": {
"@playwright/test": "^1.44.1",
"@sentry-internal/test-utils": "link:../../../test-utils",
"@sentry-internal/browser-utils": "latest || *",
"@sentry-internal/feedback": "latest || *",
"@sentry-internal/replay": "latest || *",
"@sentry-internal/replay-canvas": "latest || *",
"@sentry-internal/browser-utils": "latest || *",
"@sentry-internal/test-utils": "link:../../../test-utils",
"@sentry/browser": "latest || *",
"@sentry/core": "latest || *",
"@sentry/nextjs": "latest || *",
"@sentry/node": "latest || *",
"@sentry/opentelemetry": "latest || *",
"@sentry/react": "latest || *",
"@sentry-internal/replay": "latest || *",
"@sentry/types": "latest || *",
"@sentry/utils": "latest || *",
"@sentry/vercel-edge": "latest || *"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { NextApiRequest, NextApiResponse } from 'next';

const handler = async (_req: NextApiRequest, res: NextApiResponse): Promise<void> => {
export default async (_req: NextApiRequest, res: NextApiResponse): Promise<void> => {
res.status(200).json({ success: true });
};

module.exports = handler;
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { NextApiRequest, NextApiResponse } from 'next';

const handler = async (_req: NextApiRequest, res: NextApiResponse): Promise<void> => {
export default async (_req: NextApiRequest, res: NextApiResponse): Promise<void> => {
res.status(200).json({ success: true });
};

module.exports = handler;
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import { expect, test } from '@playwright/test';
import { waitForTransaction } from '@sentry-internal/test-utils';

const packageJson = require('../../package.json');
const nextjsVersion = packageJson.dependencies.next;
const nextjsMajor = Number(nextjsVersion.split('.')[0]);

test('should create a transaction for a CJS pages router API endpoint', async ({ request }) => {
test.skip(nextjsMajor > 13, 'Next.js does not like CJS routes after a certain point.');

const transactionPromise = waitForTransaction('nextjs-13', async transactionEvent => {
return (
transactionEvent.transaction === 'GET /api/cjs-api-endpoint' &&
Expand Down Expand Up @@ -62,6 +68,8 @@ test('should create a transaction for a CJS pages router API endpoint', async ({
});

test('should not mess up require statements in CJS API endpoints', async ({ request }) => {
test.skip(nextjsMajor > 13, 'Next.js does not like CJS routes after a certain point.');

const transactionPromise = waitForTransaction('nextjs-13', async transactionEvent => {
return (
transactionEvent.transaction === 'GET /api/cjs-api-endpoint-with-require' &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ test('should not automatically create transactions for routes that were excluded
);
});

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

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

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

let transactionPromiseReceived = false;
transactionPromise.then(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ test('Should capture an error thrown in a server component', async ({ page }) =>
contexts: {
runtime: { name: 'node', version: expect.any(String) },
trace: {
parent_span_id: expect.any(String),
span_id: expect.any(String),
trace_id: expect.any(String),
},
Expand All @@ -27,7 +26,6 @@ test('Should capture an error thrown in a server component', async ({ page }) =>
},
],
},
modules: { next: '13.2.0' },
platform: 'node',
request: {
cookies: expect.any(Object),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ const cases = [
cases.forEach(({ name, url, transactionName }) => {
test(`Should capture transactions for routes with various shapes (${name})`, async ({ request }) => {
const transactionEventPromise = waitForTransaction('nextjs-13', transactionEvent => {
console.log({ t: transactionEvent.transaction });
return transactionEvent.transaction === transactionName && transactionEvent.contexts?.trace?.op === 'http.server';
});

Expand Down
1 change: 0 additions & 1 deletion packages/nextjs/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ module.exports = {
parserOptions: {
jsx: true,
},
ignorePatterns: ['test/integration/**', 'playwright.config.ts'],
extends: ['../../.eslintrc.js'],
rules: {
'@sentry-internal/sdk/no-optional-chaining': 'off',
Expand Down
1 change: 0 additions & 1 deletion packages/nextjs/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ const baseConfig = require('../../jest/jest.config.js');

module.exports = {
...baseConfig,
testPathIgnorePatterns: ['<rootDir>/test/integration/'],
};
6 changes: 1 addition & 5 deletions packages/nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,8 @@
"fix": "eslint . --format stylish --fix",
"lint": "eslint . --format stylish",
"test": "yarn test:unit",
"test:all": "run-s test:unit test:integration",
"test:all": "run-s test:unit",
"test:unit": "jest",
"test:integration": "./test/run-integration-tests.sh && yarn test:types",
"test:integration:clean": "(cd test/integration && rimraf .cache node_modules build)",
"test:integration:client": "yarn playwright test test/integration/test/client/",
"test:integration:server": "(cd test/integration && yarn test:server)",
"test:types": "cd test/types && yarn test",
"test:watch": "jest --watch",
"vercel:branch": "source vercel/set-up-branch-for-test-app-use.sh",
Expand Down
23 changes: 0 additions & 23 deletions packages/nextjs/playwright.config.ts

This file was deleted.

39 changes: 0 additions & 39 deletions packages/nextjs/test/integration/.gitignore

This file was deleted.

This file was deleted.

5 changes: 0 additions & 5 deletions packages/nextjs/test/integration/app/clientcomponent/page.tsx

This file was deleted.

7 changes: 0 additions & 7 deletions packages/nextjs/test/integration/app/layout.tsx

This file was deleted.

This file was deleted.

8 changes: 0 additions & 8 deletions packages/nextjs/test/integration/app/servercomponent/page.tsx

This file was deleted.

44 changes: 0 additions & 44 deletions packages/nextjs/test/integration/components/Layout.tsx

This file was deleted.

20 changes: 0 additions & 20 deletions packages/nextjs/test/integration/components/List.tsx

This file was deleted.

17 changes: 0 additions & 17 deletions packages/nextjs/test/integration/components/ListDetail.tsx

This file was deleted.

19 changes: 0 additions & 19 deletions packages/nextjs/test/integration/components/ListItem.tsx

This file was deleted.

Loading
Loading