Skip to content

Commit 38bc72e

Browse files
fix: resolve NextAuth NO_SECRET error in Playwright tests
- Load .env.local explicitly in Playwright config - Pass NEXTAUTH_SECRET to webServer environment - Prevents NO_SECRET error when running production build for tests
1 parent f1861fd commit 38bc72e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

playwright.config.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import { defineConfig, devices } from "@playwright/test";
22
import dotenv from "dotenv";
3+
import path from "path";
34

4-
dotenv.config();
5+
// Load .env.local for local development
6+
dotenv.config({ path: path.resolve(__dirname, ".env.local") });
57
/**
68
* Read environment variables from file.
79
* https://github.com/motdotla/dotenv
@@ -66,5 +68,8 @@ export default defineConfig({
6668
url: "http://localhost:3000",
6769
reuseExistingServer: !process.env.CI,
6870
timeout: 120000, // Adding a longer timeout for build process
71+
env: {
72+
NEXTAUTH_SECRET: process.env.NEXTAUTH_SECRET || "test-secret-for-playwright",
73+
},
6974
},
7075
});

0 commit comments

Comments
 (0)