@@ -112,8 +112,11 @@ function filterExecArgv(arg, i, arr) {
112112 ! ArrayPrototypeSome ( kFilterArgValues , ( p ) => arg === p || ( i > 0 && arr [ i - 1 ] === p ) || StringPrototypeStartsWith ( arg , `${ p } =` ) ) ;
113113}
114114
115- function getRunArgs ( path , { inspectPort, testNamePatterns, only } ) {
115+ function getRunArgs ( path , { forceExit , inspectPort, testNamePatterns, only } ) {
116116 const argv = ArrayPrototypeFilter ( process . execArgv , filterExecArgv ) ;
117+ if ( forceExit === true ) {
118+ ArrayPrototypePush ( argv , '--test-force-exit' ) ;
119+ }
117120 if ( isUsingInspector ( ) ) {
118121 ArrayPrototypePush ( argv , `--inspect-port=${ getInspectPort ( inspectPort ) } ` ) ;
119122 }
@@ -440,14 +443,33 @@ function run(options = kEmptyObject) {
440443 validateObject ( options , 'options' ) ;
441444
442445 let { testNamePatterns, shard } = options ;
443- const { concurrency, timeout, signal, files, inspectPort, watch, setup, only } = options ;
446+ const {
447+ concurrency,
448+ timeout,
449+ signal,
450+ files,
451+ forceExit,
452+ inspectPort,
453+ watch,
454+ setup,
455+ only,
456+ } = options ;
444457
445458 if ( files != null ) {
446459 validateArray ( files , 'options.files' ) ;
447460 }
448461 if ( watch != null ) {
449462 validateBoolean ( watch , 'options.watch' ) ;
450463 }
464+ if ( forceExit != null ) {
465+ validateBoolean ( forceExit , 'options.forceExit' ) ;
466+
467+ if ( forceExit && watch ) {
468+ throw new ERR_INVALID_ARG_VALUE (
469+ 'options.forceExit' , watch , 'is not supported with watch mode' ,
470+ ) ;
471+ }
472+ }
451473 if ( only != null ) {
452474 validateBoolean ( only , 'options.only' ) ;
453475 }
@@ -501,7 +523,15 @@ function run(options = kEmptyObject) {
501523
502524 let postRun = ( ) => root . postRun ( ) ;
503525 let filesWatcher ;
504- const opts = { __proto__ : null , root, signal, inspectPort, testNamePatterns, only } ;
526+ const opts = {
527+ __proto__ : null ,
528+ root,
529+ signal,
530+ inspectPort,
531+ testNamePatterns,
532+ only,
533+ forceExit,
534+ } ;
505535 if ( watch ) {
506536 filesWatcher = watchFiles ( testFiles , opts ) ;
507537 postRun = undefined ;
0 commit comments