Skip to content

Scheduling infrastructure for absolutely everyone.

fix: load .env file in vitest config and update integration test docs (#26828)

Eunjae Lee97bfb8158d7c
diff --git a/AGENTS.md b/AGENTS.md
index 5d960e83b54..340304999fe 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -48,10 +48,10 @@ yarn vitest run path/to/file.test.ts
yarn vitest run path/to/file.test.ts --testNamePattern="specific test name"
# Integration test specific file
-yarn test path/to/file.integration-test.ts -- --integrationTestsOnly
+VITEST_MODE=integration yarn test path/to/file.integration-test.ts
# Integration test specific file + specific test
-yarn test path/to/file.integration-test.ts --testNamePattern="specific test name" -- --integrationTestsOnly
+VITEST_MODE=integration yarn test path/to/file.integration-test.ts --testNamePattern="specific test name"
# E2E test specific file
PLAYWRIGHT_HEADLESS=1 yarn e2e path/to/file.e2e.ts
diff --git a/agents/commands.md b/agents/commands.md
index f6da7d8a880..b818c526ecb 100644
--- a/agents/commands.md
+++ b/agents/commands.md
@@ -34,9 +34,9 @@
### Integration Tests
-- `yarn test -- --integrationTestsOnly` - Run integration tests (vitest)
-- `yarn test <filename> -- --integrationTestsOnly` - Run integration tests for specific file
-- `yarn test <filename> -t "<testName>" -- --integrationTestsOnly` - Run specific integration test by name for specific file
+- `VITEST_MODE=integration yarn test` - Run integration tests (vitest)
+- `VITEST_MODE=integration yarn test <filename>` - Run integration tests for specific file
+- `VITEST_MODE=integration yarn test <filename> -t "<testName>"` - Run specific integration test by name for specific file
### End-to-End Tests
@@ -73,7 +73,7 @@
yarn vitest run packages/lib/some-file.test.ts
# Integration test specific file
-yarn test routing-form-response-denormalized.integration-test.ts -- --integrationTestsOnly
+VITEST_MODE=integration yarn test routing-form-response-denormalized.integration-test.ts
# E2E test specific file
yarn e2e tests/booking-flow.e2e.ts
diff --git a/vitest.config.mts b/vitest.config.mts
index c6655892594..008ec4f359b 100644
--- a/vitest.config.mts
+++ b/vitest.config.mts
@@ -1,7 +1,15 @@
import path from "node:path";
import react from "@vitejs/plugin-react";
+import { loadEnv } from "vite";
import { defineConfig } from "vitest/config";
+const env = loadEnv("", process.cwd(), "");
+for (const [key, value] of Object.entries(env)) {
+ if (process.env[key] === undefined) {
+ process.env[key] = value;
+ }
+}
+
const vitestMode = process.env.VITEST_MODE;
// Support both new VITEST_MODE env var and legacy CLI flags for backwards compatibility
// The CLI flags are passed through but Vitest 4.0 doesn't reject them when using yarn test