@@ -650,6 +650,29 @@ describe('require(\'node:test\').run', { concurrency: true }, () => {
650650 } ) ;
651651} ) ;
652652
653+ describe ( 'env' , ( ) => {
654+ it ( 'should allow env variables to be configured' , async ( ) => {
655+ // Need to inherit some process.env variables so it runs reliably across different environments.
656+ const env = { ...process . env , FOOBAR : 'FUZZBUZZ' } ;
657+ // Set a variable on main process env and test it does not exist within test env.
658+ process . env . ABC = 'XYZ' ;
659+
660+ const stream = run ( { files : [ join ( testFixtures , 'process-env.js' ) ] , env } ) ;
661+ stream . on ( 'test:fail' , common . mustNotCall ( ) ) ;
662+ stream . on ( 'test:pass' , common . mustCall ( 1 ) ) ;
663+ // eslint-disable-next-line no-unused-vars
664+ for await ( const _ of stream ) ;
665+ delete process . env . ABC ;
666+ } ) ;
667+
668+ it ( 'should throw error when env is specified with isolation=none' , async ( ) => {
669+ assert . throws ( ( ) => run ( { env : { foo : 'bar' } , isolation : 'none' } ) , {
670+ code : 'ERR_INVALID_ARG_VALUE' ,
671+ message : / T h e p r o p e r t y ' o p t i o n s \. e n v ' i s n o t s u p p o r t e d w i t h i s o l a t i o n = ' n o n e ' \. R e c e i v e d { f o o : ' b a r ' } /
672+ } ) ;
673+ } ) ;
674+ } ) ;
675+
653676describe ( 'forceExit' , ( ) => {
654677 it ( 'throws for non-boolean values' , ( ) => {
655678 [ Symbol ( ) , { } , 0 , 1 , '1' , Promise . resolve ( [ ] ) ] . forEach ( ( forceExit ) => {
0 commit comments