File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed
Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -732,14 +732,14 @@ async function readTestConfig(fixtureDir: string) {
732732 // config.ts file doesn't exist, that's fine
733733 }
734734
735- // Read environment variables from .env files (try mode-specific first )
735+ // Read and merge environment variables from .env files (matching Vite's loadEnv behavior )
736736 let envVars : Record < string , string > = { } ;
737- const envFiles = [ ".env.test " , ".env.local" , ".env" ] ;
737+ const envFiles = [ ".env" , ".env.local" , ".env.test " ] ;
738738
739739 for ( const envFile of envFiles ) {
740740 try {
741741 const envContent = readFileSync ( join ( fixtureDir , envFile ) , "utf-8" ) ;
742- envVars = Object . fromEntries (
742+ const fileVars = Object . fromEntries (
743743 envContent
744744 . split ( "\n" )
745745 . filter ( ( line ) => line . trim ( ) && ! line . startsWith ( "#" ) )
@@ -748,7 +748,8 @@ async function readTestConfig(fixtureDir: string) {
748748 return [ key . trim ( ) , valueParts . join ( "=" ) . trim ( ) ] ;
749749 } ) ,
750750 ) ;
751- break ; // Stop after first successful read
751+ // Merge with precedence: later files override earlier ones
752+ envVars = { ...envVars , ...fileVars } ;
752753 } catch {
753754 // Try next file
754755 }
You can’t perform that action at this time.
0 commit comments