@@ -112,8 +112,11 @@ function filterExecArgv(arg, i, arr) {
112
112
! ArrayPrototypeSome ( kFilterArgValues , ( p ) => arg === p || ( i > 0 && arr [ i - 1 ] === p ) || StringPrototypeStartsWith ( arg , `${ p } =` ) ) ;
113
113
}
114
114
115
- function getRunArgs ( path , { inspectPort, testNamePatterns, only } ) {
115
+ function getRunArgs ( path , { forceExit , inspectPort, testNamePatterns, only } ) {
116
116
const argv = ArrayPrototypeFilter ( process . execArgv , filterExecArgv ) ;
117
+ if ( forceExit === true ) {
118
+ ArrayPrototypePush ( argv , '--test-force-exit' ) ;
119
+ }
117
120
if ( isUsingInspector ( ) ) {
118
121
ArrayPrototypePush ( argv , `--inspect-port=${ getInspectPort ( inspectPort ) } ` ) ;
119
122
}
@@ -440,14 +443,33 @@ function run(options = kEmptyObject) {
440
443
validateObject ( options , 'options' ) ;
441
444
442
445
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 ;
444
457
445
458
if ( files != null ) {
446
459
validateArray ( files , 'options.files' ) ;
447
460
}
448
461
if ( watch != null ) {
449
462
validateBoolean ( watch , 'options.watch' ) ;
450
463
}
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
+ }
451
473
if ( only != null ) {
452
474
validateBoolean ( only , 'options.only' ) ;
453
475
}
@@ -501,7 +523,15 @@ function run(options = kEmptyObject) {
501
523
502
524
let postRun = ( ) => root . postRun ( ) ;
503
525
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
+ } ;
505
535
if ( watch ) {
506
536
filesWatcher = watchFiles ( testFiles , opts ) ;
507
537
postRun = undefined ;
0 commit comments