@@ -481,6 +481,13 @@ describe('require(\'node:test\').run', { concurrency: true }, () => {
481
481
} ) ;
482
482
} ) ;
483
483
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
+
484
491
it ( 'should only allow object as options' , ( ) => {
485
492
[ Symbol ( ) , [ ] , ( ) => { } , 0 , 1 , 0n , 1n , '' , '1' , true , false ]
486
493
. forEach ( ( options ) => assert . throws ( ( ) => run ( options ) , {
@@ -513,6 +520,33 @@ describe('require(\'node:test\').run', { concurrency: true }, () => {
513
520
for await ( const _ of stream ) ;
514
521
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 / ) ;
515
522
} ) ;
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
+ } ) ;
516
550
} ) ;
517
551
518
552
describe ( 'forceExit' , ( ) => {
0 commit comments