File tree Expand file tree Collapse file tree
packages/vitest/src/node/plugins
test/e2e/fixtures/config/browser-define Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -149,13 +149,13 @@ export function TestConfigPlugin(
149149 // We inject the defines at runtime in non-browser tests,
150150 // but keep the original behaviour in the browser mode
151151 const resolvedTestConfig = testConfig as ResolvedConfig
152- if ( sharedServer ) {
152+ if ( isBrowserEnabled ) {
153+ resolvedTestConfig . defines = { }
154+ }
155+ else if ( sharedServer ) {
153156 resolvedTestConfig . defines = sharedServer . defines
154157 resolvedTestConfig . _scriptDefines = sharedServer . scriptDefines
155158 }
156- else if ( isBrowserEnabled ) {
157- resolvedTestConfig . defines = config . define || { }
158- }
159159 else {
160160 const { defines, scriptDefines } = deleteDefineConfig ( config )
161161 resolvedTestConfig . defines = defines
Original file line number Diff line number Diff line change 11import { test , expect } from 'vitest'
22
3+ declare const FOO : string
4+
35test ( 'passes' , ( ) => {
6+ expect ( FOO ) . toBe ( 'BAR' )
47 expect ( process . env . TEST_PROCESS_ENV ) . toBe ( 'PROCESS_OK' )
58 expect ( import . meta. env . TEST_META_ENV ) . toBe ( 'META_OK' )
69} )
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import { defineConfig } from 'vitest/config'
33
44let config = defineConfig ( {
55 define : {
6+ FOO : JSON . stringify ( 'BAR' ) ,
67 'process.env.TEST_PROCESS_ENV' : JSON . stringify ( 'PROCESS_OK' ) ,
78 'import.meta.env.TEST_META_ENV' : JSON . stringify ( 'META_OK' ) ,
89 } ,
You can’t perform that action at this time.
0 commit comments