@@ -533,22 +533,60 @@ describe('require(\'node:test\').run', { concurrency: true }, () => {
533533 for await ( const _ of stream ) ;
534534 } ) ;
535535
536- it ( 'should throw if an invalid cwd is provided' , async ( ) => {
537- assert . throws ( ( ) => run ( {
536+ it ( 'should handle a non-existent directory being provided as cwd' , async ( ) => {
537+ const diagnostics = [ ] ;
538+ const stream = run ( {
538539 cwd : fixtures . path ( 'test-runner' , 'cwd' , 'non-existing' )
539- } ) , {
540- code : 'ERR_INVALID_ARG_VALUE' ,
541- message : / e x p e c t s a n e x i s t i n g d i r e c t o r y /
542540 } ) ;
541+ stream . on ( 'test:fail' , common . mustNotCall ( ) ) ;
542+ stream . on ( 'test:pass' , common . mustNotCall ( ) ) ;
543+ stream . on ( 'test:stderr' , common . mustNotCall ( ) ) ;
544+ stream . on ( 'test:diagnostic' , ( { message } ) => {
545+ diagnostics . push ( message ) ;
546+ } ) ;
547+
548+ // eslint-disable-next-line no-unused-vars
549+ for await ( const _ of stream ) ;
550+ for ( const entry of [
551+ 'tests 0' ,
552+ 'suites 0' ,
553+ 'pass 0' ,
554+ 'fail 0' ,
555+ 'cancelled 0' ,
556+ 'skipped 0' ,
557+ 'todo 0' ,
558+ ]
559+ ) {
560+ assert . strictEqual ( diagnostics . includes ( entry ) , true ) ;
561+ }
543562 } ) ;
544563
545- it ( 'should throw if a file is provided as cwd' , async ( ) => {
546- assert . throws ( ( ) => run ( {
564+ it ( 'should handle a non-existent file being provided as cwd' , async ( ) => {
565+ const diagnostics = [ ] ;
566+ const stream = run ( {
547567 cwd : fixtures . path ( 'test-runner' , 'default-behavior' , 'test' , 'random.cjs' )
548- } ) , {
549- code : 'ERR_INVALID_ARG_VALUE' ,
550- message : / e x p e c t s a d i r e c t o r y , a f i l e w a s p r o v i d e d /
551568 } ) ;
569+ stream . on ( 'test:fail' , common . mustNotCall ( ) ) ;
570+ stream . on ( 'test:pass' , common . mustNotCall ( ) ) ;
571+ stream . on ( 'test:stderr' , common . mustNotCall ( ) ) ;
572+ stream . on ( 'test:diagnostic' , ( { message } ) => {
573+ diagnostics . push ( message ) ;
574+ } ) ;
575+
576+ // eslint-disable-next-line no-unused-vars
577+ for await ( const _ of stream ) ;
578+ for ( const entry of [
579+ 'tests 0' ,
580+ 'suites 0' ,
581+ 'pass 0' ,
582+ 'fail 0' ,
583+ 'cancelled 0' ,
584+ 'skipped 0' ,
585+ 'todo 0' ,
586+ ]
587+ ) {
588+ assert . strictEqual ( diagnostics . includes ( entry ) , true ) ;
589+ }
552590 } ) ;
553591
554592 it ( 'should run with different cwd while in watch mode' , async ( ) => {
0 commit comments