Skip to content

Commit bf2e634

Browse files
committed
fix(test-utils): Inherit environment variables in Playwright webServer
The webServer config was setting `env: { PORT: ... }` which REPLACES the parent environment instead of merging with it. This meant env vars like NEXT_PUBLIC_SENTRY_SPOTLIGHT weren't being passed to the Next.js dev server, causing the Spotlight auto-enablement test to fail. By spreading `...process.env`, we now inherit all environment variables from the CI runner, allowing the valueInjectionLoader to work correctly.
1 parent e5409e6 commit bf2e634

File tree

3 files changed

+4
-17
lines changed

3 files changed

+4
-17
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -993,15 +993,7 @@ jobs:
993993

994994
- name: Set Spotlight env var for spotlight tests
995995
if: contains(matrix.test-application, 'spotlight')
996-
run: |
997-
echo "NEXT_PUBLIC_SENTRY_SPOTLIGHT=true" >> $GITHUB_ENV
998-
echo "Setting NEXT_PUBLIC_SENTRY_SPOTLIGHT=true for spotlight test"
999-
1000-
- name: Debug Spotlight env var
1001-
if: contains(matrix.test-application, 'spotlight')
1002-
run: |
1003-
echo "NEXT_PUBLIC_SENTRY_SPOTLIGHT=$NEXT_PUBLIC_SENTRY_SPOTLIGHT"
1004-
env | grep -i spotlight || echo "No SPOTLIGHT vars found"
996+
run: echo "NEXT_PUBLIC_SENTRY_SPOTLIGHT=true" >> $GITHUB_ENV
1005997

1006998
- name: Build E2E app
1007999
working-directory: ${{ runner.temp }}/test-application

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ export function getPlaywrightConfig(
9090
stdout: 'pipe',
9191
stderr: 'pipe',
9292
env: {
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,
9396
PORT: appPort.toString(),
9497
},
9598
});

packages/nextjs/src/config/withSentryConfig.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -355,14 +355,6 @@ function getFinalConfigObject(
355355
const spotlightConfig =
356356
incomingUserNextConfigObject.env?.NEXT_PUBLIC_SENTRY_SPOTLIGHT ?? process.env.NEXT_PUBLIC_SENTRY_SPOTLIGHT;
357357

358-
// Debug: Log spotlight config detection
359-
// eslint-disable-next-line no-console
360-
console.log('[@sentry/nextjs] Spotlight config detection:', {
361-
fromNextConfigEnv: incomingUserNextConfigObject.env?.NEXT_PUBLIC_SENTRY_SPOTLIGHT,
362-
fromProcessEnv: process.env.NEXT_PUBLIC_SENTRY_SPOTLIGHT,
363-
resolved: spotlightConfig,
364-
});
365-
366358
let turboPackConfig: TurbopackOptions | undefined;
367359

368360
// IMPORTANT: Always construct turbopack config if the Next.js version supports it,

0 commit comments

Comments
 (0)