Skip to content

Commit e670133

Browse files
committed
test(e2e): Update create-next-app test app
1 parent da59f96 commit e670133

16 files changed

+246
-321
lines changed
Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +0,0 @@
1-
interface Window {
2-
recordedTransactions?: string[];
3-
capturedExceptionId?: string;
4-
}
Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,13 @@
11
import * as Sentry from '@sentry/nextjs';
22

3-
declare global {
4-
namespace globalThis {
5-
var transactionIds: string[];
6-
}
7-
}
8-
93
export function register() {
104
if (process.env.NEXT_RUNTIME === 'nodejs') {
115
Sentry.init({
126
environment: 'qa', // dynamic sampling bias to keep transactions
137
dsn: process.env.NEXT_PUBLIC_E2E_TEST_DSN,
148
// Adjust this value in production, or use tracesSampler for greater control
159
tracesSampleRate: 1.0,
16-
integrations: [Sentry.localVariablesIntegration()],
17-
});
18-
19-
Sentry.addEventProcessor(event => {
20-
global.transactionIds = global.transactionIds || [];
21-
22-
if (event.type === 'transaction') {
23-
const eventId = event.event_id;
24-
25-
if (eventId) {
26-
global.transactionIds.push(eventId);
27-
}
28-
}
29-
30-
return event;
10+
tunnel: 'http://localhost:3031',
3111
});
3212
}
3313
}

dev-packages/e2e-tests/test-applications/create-next-app/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
"typescript": "4.9.5"
2424
},
2525
"devDependencies": {
26-
"@playwright/test": "^1.44.1"
26+
"@playwright/test": "^1.44.1",
27+
"@sentry-internal/test-utils": "link:../../../test-utils"
2728
},
2829
"volta": {
2930
"extends": "../../package.json"
Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
1-
import * as Sentry from '@sentry/nextjs';
21
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
32
import type { NextApiRequest, NextApiResponse } from 'next';
43

54
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
6-
const exceptionId = Sentry.captureException(new Error('This is an error'));
7-
8-
await Sentry.flush(2000);
9-
10-
res.status(200).json({ exceptionId });
5+
throw new Error('I am a server error!');
116
}

dev-packages/e2e-tests/test-applications/create-next-app/pages/api/success.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default function handler(req: NextApiRequest, res: NextApiResponse) {
77

88
Sentry.flush().then(() => {
99
res.status(200).json({
10-
transactionIds: global.transactionIds,
10+
transactionIds: [],
1111
});
1212
});
1313
}

dev-packages/e2e-tests/test-applications/create-next-app/pages/index.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import * as Sentry from '@sentry/nextjs';
21
import Head from 'next/head';
32
import Link from 'next/link';
43

@@ -17,8 +16,7 @@ export default function Home() {
1716
value="Capture Exception"
1817
id="exception-button"
1918
onClick={() => {
20-
const eventId = Sentry.captureException(new Error('I am an error!'));
21-
window.capturedExceptionId = eventId;
19+
throw new Error('I am an error!');
2220
}}
2321
/>
2422
<Link href="/user/5" id="navigation">
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { getPlaywrightConfig } from '@sentry-internal/test-utils';
2+
3+
const testEnv = process.env.TEST_ENV;
4+
5+
if (!testEnv) {
6+
throw new Error('No test env defined');
7+
}
8+
9+
const config = getPlaywrightConfig({
10+
startCommand: testEnv === 'development' ? `pnpm next dev -p 3030` : `pnpm next start -p 3030`,
11+
});
12+
13+
export default config;

dev-packages/e2e-tests/test-applications/create-next-app/playwright.config.ts

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

dev-packages/e2e-tests/test-applications/create-next-app/sentry.client.config.ts

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,8 @@ import * as Sentry from '@sentry/nextjs';
77
Sentry.init({
88
environment: 'qa', // dynamic sampling bias to keep transactions
99
dsn: process.env.NEXT_PUBLIC_E2E_TEST_DSN,
10-
// Adjust this value in production, or use tracesSampler for greater control
11-
tracesSampleRate: 1.0,
12-
13-
// ...
14-
// Note: if you want to override the automatic release value, do not set a
15-
// `release` value here - use the environment variable `SENTRY_RELEASE`, so
16-
// that it will also get attached to your source maps
17-
});
1810

19-
Sentry.addEventProcessor(event => {
20-
if (
21-
event.type === 'transaction' &&
22-
(event.contexts?.trace?.op === 'pageload' || event.contexts?.trace?.op === 'navigation')
23-
) {
24-
const eventId = event.event_id;
25-
if (eventId) {
26-
window.recordedTransactions = window.recordedTransactions || [];
27-
window.recordedTransactions.push(eventId);
28-
}
29-
}
11+
tracesSampleRate: 1.0,
3012

31-
return event;
13+
tunnel: 'http://localhost:3031',
3214
});
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { startEventProxyServer } from '@sentry-internal/test-utils';
2+
3+
startEventProxyServer({
4+
port: 3031,
5+
proxyServerName: 'create-next-app',
6+
});

dev-packages/e2e-tests/test-applications/create-next-app/tests/behaviour-client.test.ts

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

0 commit comments

Comments
 (0)