@@ -605,9 +605,23 @@ class Test extends AsyncResource {
605
605
throw new ERR_INVALID_ARG_TYPE ( 'options.concurrency' , [ 'boolean' , 'number' ] , concurrency ) ;
606
606
}
607
607
608
+ // Take timeout from cli
609
+ const cliTimeout = this . config . timeout ;
610
+ if ( cliTimeout != null && cliTimeout !== Infinity ) {
611
+ if ( ! ( this . name === '<root>' && this . parent === null ) &&
612
+ this . constructor . name !== 'FileTest' &&
613
+ this . constructor . name !== 'Suite' ) {
614
+ validateNumber ( cliTimeout , 'options.timeout' , 0 , TIMEOUT_MAX ) ;
615
+ this . timeout = cliTimeout ;
616
+ }
617
+ }
618
+
619
+ // Take timeout from options
608
620
if ( timeout != null && timeout !== Infinity ) {
609
- validateNumber ( timeout , 'options.timeout' , 0 , TIMEOUT_MAX ) ;
610
- this . timeout = timeout ;
621
+ if ( ! ( this . name === '<root>' && this . parent === null ) ) {
622
+ validateNumber ( timeout , 'options.timeout' , 0 , TIMEOUT_MAX ) ;
623
+ this . timeout = timeout ;
624
+ }
611
625
}
612
626
613
627
if ( skip ) {
@@ -788,8 +802,6 @@ class Test extends AsyncResource {
788
802
}
789
803
790
804
createSubtest ( Factory , name , options , fn , overrides ) {
791
- const timeoutPerTest = this . config . timeoutPerTest ;
792
-
793
805
if ( typeof name === 'function' ) {
794
806
fn = name ;
795
807
} else if ( name !== null && typeof name === 'object' ) {
@@ -799,18 +811,9 @@ class Test extends AsyncResource {
799
811
fn = options ;
800
812
}
801
813
802
- if ( options !== null && typeof options === 'object' ) {
803
- if ( this . childNumber > 0 && options . timeout === undefined && timeoutPerTest !== Infinity ) {
804
- options . timeout = timeoutPerTest ;
805
- }
806
- }
807
814
808
815
if ( options === null || typeof options !== 'object' ) {
809
- if ( this . childNumber > 0 && timeoutPerTest !== Infinity ) {
810
- options = { __proto__ : null , timeout : timeoutPerTest } ;
811
- } else {
812
- options = kEmptyObject ;
813
- }
816
+ options = kEmptyObject ;
814
817
}
815
818
816
819
let parent = this ;
0 commit comments