Skip to content

Commit c7652fe

Browse files
committed
Revert "fix(e2e): Fix nextjs-15-spotlight test by using explicit spotlight passing"
This reverts commit 939e0cd.
1 parent f24fa13 commit c7652fe

File tree

4 files changed

+7
-38
lines changed

4 files changed

+7
-38
lines changed

dev-packages/e2e-tests/test-applications/nextjs-15-spotlight/instrumentation-client.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
import * as Sentry from '@sentry/nextjs';
22

3-
// In Next.js 15, Turbopack is the default dev bundler. Turbopack doesn't replace
4-
// process.env vars in node_modules code, which prevents the SDK's auto-detection
5-
// from working. As a workaround, we explicitly pass the spotlight value from
6-
// process.env which Next.js DOES replace in user code.
7-
//
8-
// Note: Auto-detection DOES work in:
9-
// - Next.js with webpack (older versions or configured to use webpack)
10-
// - Other frameworks like Vite, Create React App, etc.
3+
// In Next.js 15 Turbopack dev mode, custom loaders aren't applied to instrumentation files.
4+
// So we need to explicitly pass the spotlight value from process.env which Next.js DOES replace.
5+
// This is a workaround for the valueInjectionLoader not working in Turbopack.
116
const spotlightValue = process.env.NEXT_PUBLIC_SENTRY_SPOTLIGHT === 'true';
127

138
console.log('[Sentry Debug] Spotlight from process.env:', spotlightValue);

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
"scripts": {
66
"dev": "next dev -p 3030",
77
"build": "next build",
8-
"start": "next start -p 3030",
98
"test": "playwright test",
109
"test:build": "pnpm install",
1110
"test:assert": "pnpm test"

dev-packages/e2e-tests/test-applications/nextjs-15-spotlight/playwright.config.mjs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
import { getPlaywrightConfig } from '@sentry-internal/test-utils';
22

33
const config = getPlaywrightConfig({
4-
// Use next dev to test development-mode behavior where Spotlight is auto-enabled.
5-
// Note: In Next.js 15, Turbopack is the default dev bundler and doesn't replace
6-
// process.env vars in node_modules code. This prevents the SDK's auto-detection
7-
// from working, so the test explicitly passes the spotlight value.
4+
// Use next dev to test development-mode behavior where Spotlight is auto-enabled
85
startCommand: 'pnpm dev',
96
port: 3030,
107
eventProxyFile: 'start-event-proxy.mjs',

dev-packages/test-utils/src/playwright-config.ts

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -82,30 +82,6 @@ export function getPlaywrightConfig(
8282
};
8383

8484
if (startCommand) {
85-
// Filter environment variables to only include those that are safe and needed
86-
// We avoid passing ALL env vars to prevent unintended side effects in tests
87-
const filteredEnv = Object.fromEntries(
88-
Object.entries(process.env).filter(([key]) => {
89-
// Include E2E test DSN variables (needed by all test apps)
90-
if (key.includes('E2E_TEST_DSN') || key === 'E2E_TEST_SENTRY_ORG_SLUG' || key === 'E2E_TEST_SENTRY_PROJECT') {
91-
return true;
92-
}
93-
// Include Spotlight environment variables (needed for Spotlight tests)
94-
if (key.includes('SENTRY_SPOTLIGHT')) {
95-
return true;
96-
}
97-
// Include Node/npm related variables for proper execution
98-
if (key === 'PATH' || key === 'NODE_ENV' || key === 'HOME' || key === 'USER') {
99-
return true;
100-
}
101-
// Include CI variable for proper test configuration
102-
if (key === 'CI') {
103-
return true;
104-
}
105-
return false;
106-
}),
107-
);
108-
10985
// @ts-expect-error - we set `config.webserver` to an array above.
11086
// TS just can't infer that and thinks it could also be undefined or an object.
11187
config.webServer.push({
@@ -114,7 +90,9 @@ export function getPlaywrightConfig(
11490
stdout: 'pipe',
11591
stderr: 'pipe',
11692
env: {
117-
...filteredEnv,
93+
// Inherit all environment variables from the parent process
94+
// This is needed for env vars like NEXT_PUBLIC_SENTRY_SPOTLIGHT to be passed through
95+
...process.env,
11896
PORT: appPort.toString(),
11997
},
12098
});

0 commit comments

Comments
 (0)