File tree Expand file tree Collapse file tree
e2e/browser-mode/fixtures/env/tests Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -35,4 +35,11 @@ describe('browser env injection', () => {
3535 it ( 'should expose NODE_ENV via import.meta.env in browser mode' , ( ) => {
3636 expect ( import . meta. env . NODE_ENV ) . toBe ( 'test' ) ;
3737 } ) ;
38+
39+ it ( 'should expose the RSTEST flag in browser mode' , ( ) => {
40+ // Matches Node mode, where `prepare.ts` sets `process.env.RSTEST = 'true'`.
41+ // See https://github.com/web-infra-dev/rstest/issues/1351
42+ expect ( process . env . RSTEST ) . toBe ( 'true' ) ;
43+ expect ( import . meta. env . RSTEST ) . toBe ( 'true' ) ;
44+ } ) ;
3845} ) ;
Original file line number Diff line number Diff line change @@ -830,11 +830,15 @@ const getRuntimeConfigFromProject = (
830830 } = project . normalizedConfig ;
831831
832832 return {
833- // Propagate NODE_ENV from the host so `import.meta.env.NODE_ENV` resolves
834- // to `'test'` in browser tests (matches Node mode). User-supplied `env`
835- // wins so explicit overrides still take effect.
833+ // Propagate NODE_ENV and the RSTEST flag from the host so
834+ // `process.env.NODE_ENV` / `process.env.RSTEST` (rewritten to the
835+ // `rstest.env` symbol store) resolve in browser tests the same way they do
836+ // in Node mode, where `prepare.ts` sets them on the real `process.env`.
837+ // User-supplied `env` wins so explicit overrides still take effect.
838+ // See https://github.com/web-infra-dev/rstest/issues/1351
836839 env : {
837840 NODE_ENV : process . env . NODE_ENV ,
841+ RSTEST : 'true' ,
838842 ...env ,
839843 } ,
840844 testNamePattern,
You can’t perform that action at this time.
0 commit comments