Skip to content

Commit 9e8bc8c

Browse files
committed
fix: streamline environment variable checks for Supabase configuration
1 parent eaca05e commit 9e8bc8c

1 file changed

Lines changed: 14 additions & 8 deletions

File tree

frontend/scripts/integration.test.mjs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,28 @@ import assert from "node:assert/strict";
22
import crypto from "node:crypto";
33
import { createClient } from "@supabase/supabase-js";
44

5-
const required = [
6-
"SUPABASE_URL",
7-
"SUPABASE_ANON_KEY",
8-
"TEST_TEACHER_EMAIL",
9-
"TEST_TEACHER_PASSWORD"
10-
];
5+
const required = ["TEST_TEACHER_EMAIL", "TEST_TEACHER_PASSWORD"];
116

127
for (const key of required) {
138
if (!process.env[key]) {
149
throw new Error(`Missing required env var: ${key}`);
1510
}
1611
}
1712

13+
const supabaseUrlEnv = process.env.SUPABASE_URL ?? process.env.NEXT_PUBLIC_SUPABASE_URL ?? "";
14+
const supabaseAnonKeyEnv = process.env.SUPABASE_ANON_KEY ?? process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY ?? "";
15+
16+
if (!supabaseUrlEnv) {
17+
throw new Error("Missing required env var: SUPABASE_URL or NEXT_PUBLIC_SUPABASE_URL");
18+
}
19+
20+
if (!supabaseAnonKeyEnv) {
21+
throw new Error("Missing required env var: SUPABASE_ANON_KEY or NEXT_PUBLIC_SUPABASE_ANON_KEY");
22+
}
23+
1824
const baseUrl = (process.env.TEST_BASE_URL ?? "http://localhost:3000").replace(/\/+$/, "");
19-
const supabaseUrl = process.env.SUPABASE_URL;
20-
const supabaseAnonKey = process.env.SUPABASE_ANON_KEY;
25+
const supabaseUrl = supabaseUrlEnv;
26+
const supabaseAnonKey = supabaseAnonKeyEnv;
2127
const email = process.env.TEST_TEACHER_EMAIL;
2228
const password = process.env.TEST_TEACHER_PASSWORD;
2329

0 commit comments

Comments
 (0)