@@ -481,6 +481,13 @@ describe('require(\'node:test\').run', { concurrency: true }, () => {
481481 } ) ;
482482 } ) ;
483483
484+ it ( 'should only allow a string in options.cwd' , async ( ) => {
485+ [ Symbol ( ) , { } , [ ] , ( ) => { } , 0 , 1 , 0n , 1n , true , false ]
486+ . forEach ( ( cwd ) => assert . throws ( ( ) => run ( { cwd } ) , {
487+ code : 'ERR_INVALID_ARG_TYPE'
488+ } ) ) ;
489+ } ) ;
490+
484491 it ( 'should only allow object as options' , ( ) => {
485492 [ Symbol ( ) , [ ] , ( ) => { } , 0 , 1 , 0n , 1n , '' , '1' , true , false ]
486493 . forEach ( ( options ) => assert . throws ( ( ) => run ( options ) , {
@@ -513,6 +520,33 @@ describe('require(\'node:test\').run', { concurrency: true }, () => {
513520 for await ( const _ of stream ) ;
514521 assert . match ( stderr , / W a r n i n g : n o d e : t e s t r u n \( \) i s b e i n g c a l l e d r e c u r s i v e l y / ) ;
515522 } ) ;
523+
524+ it ( 'should run with different cwd' , async ( ) => {
525+ const stream = run ( {
526+ cwd : fixtures . path ( 'test-runner' , 'cwd' )
527+ } ) ;
528+ stream . on ( 'test:fail' , common . mustNotCall ( ) ) ;
529+ stream . on ( 'test:pass' , common . mustCall ( 1 ) ) ;
530+
531+ // eslint-disable-next-line no-unused-vars
532+ for await ( const _ of stream ) ;
533+ } ) ;
534+
535+ it ( 'should run with different cwd while in watch mode' , async ( ) => {
536+ const controller = new AbortController ( ) ;
537+ const stream = run ( {
538+ cwd : fixtures . path ( 'test-runner' , 'cwd' ) ,
539+ watch : true ,
540+ signal : controller . signal ,
541+ } ) . on ( 'data' , function ( { type } ) {
542+ if ( type === 'test:watch:drained' ) {
543+ controller . abort ( ) ;
544+ }
545+ } ) ;
546+
547+ stream . on ( 'test:fail' , common . mustNotCall ( ) ) ;
548+ stream . on ( 'test:pass' , common . mustCall ( 1 ) ) ;
549+ } ) ;
516550} ) ;
517551
518552describe ( 'forceExit' , ( ) => {
0 commit comments