@@ -45,7 +45,6 @@ const {
45
45
createDeferredCallback,
46
46
countCompletedTest,
47
47
isTestFailureError,
48
- parseCommandLine,
49
48
} = require ( 'internal/test_runner/utils' ) ;
50
49
const {
51
50
createDeferredPromise,
@@ -79,14 +78,6 @@ const kHookNames = ObjectSeal(['before', 'after', 'beforeEach', 'afterEach']);
79
78
const kUnwrapErrors = new SafeSet ( )
80
79
. add ( kTestCodeFailure ) . add ( kHookFailure )
81
80
. add ( 'uncaughtException' ) . add ( 'unhandledRejection' ) ;
82
- const {
83
- forceExit,
84
- sourceMaps,
85
- testNamePatterns,
86
- testSkipPatterns,
87
- testOnlyFlag,
88
- updateSnapshots,
89
- } = parseCommandLine ( ) ;
90
81
let kResistStopPropagation ;
91
82
let assertObj ;
92
83
let findSourceMap ;
@@ -132,7 +123,7 @@ function lazyAssertObject(harness) {
132
123
const { getOptionValue } = require ( 'internal/options' ) ;
133
124
if ( getOptionValue ( '--experimental-test-snapshots' ) ) {
134
125
const { SnapshotManager } = require ( 'internal/test_runner/snapshot' ) ;
135
- harness . snapshotManager = new SnapshotManager ( updateSnapshots ) ;
126
+ harness . snapshotManager = new SnapshotManager ( harness . config . updateSnapshots ) ;
136
127
assertObj . set ( 'snapshot' , harness . snapshotManager . createAssert ( ) ) ;
137
128
}
138
129
}
@@ -360,7 +351,7 @@ class Test extends AsyncResource {
360
351
outerSignal ;
361
352
#reportedSubtest;
362
353
363
- constructor ( options ) {
354
+ constructor ( options , config ) {
364
355
super ( 'Test' ) ;
365
356
366
357
let { fn, name, parent } = options ;
@@ -388,7 +379,7 @@ class Test extends AsyncResource {
388
379
if ( parent === null ) {
389
380
this . concurrency = 1 ;
390
381
this . nesting = 0 ;
391
- this . only = testOnlyFlag ;
382
+ this . only = config ?. testOnlyFlag ;
392
383
this . reporter = new TestsStream ( ) ;
393
384
this . runOnlySubtests = this . only ;
394
385
this . childNumber = 0 ;
@@ -430,6 +421,7 @@ class Test extends AsyncResource {
430
421
this . parent . filteredSubtestCount ++ ;
431
422
}
432
423
424
+ const { testOnlyFlag } = config ?? this . root . harness . config ;
433
425
if ( testOnlyFlag && only === false ) {
434
426
fn = noop ;
435
427
}
@@ -501,6 +493,11 @@ class Test extends AsyncResource {
501
493
this . waitingOn = 0 ;
502
494
this . finished = false ;
503
495
496
+ if ( name === '<root>' && config != null ) {
497
+ this . harness = { __proto__ : null , config } ;
498
+ }
499
+
500
+ const { testOnlyFlag } = config ?? this . root . harness . config ;
504
501
if ( ! testOnlyFlag && ( only || this . runOnlySubtests ) ) {
505
502
const warning =
506
503
"'only' and 'runOnly' require the --test-only command-line option." ;
@@ -517,7 +514,7 @@ class Test extends AsyncResource {
517
514
file : loc [ 2 ] ,
518
515
} ;
519
516
520
- if ( sourceMaps === true ) {
517
+ if ( config ?. sourceMaps === true ) {
521
518
const map = lazyFindSourceMap ( this . loc . file ) ;
522
519
const entry = map ?. findEntry ( this . loc . line - 1 , this . loc . column - 1 ) ;
523
520
@@ -535,6 +532,7 @@ class Test extends AsyncResource {
535
532
}
536
533
537
534
willBeFiltered ( ) {
535
+ const { testOnlyFlag, testNamePatterns, testSkipPatterns } = this . root ?. harness ?. config || { } ;
538
536
if ( testOnlyFlag && ! this . only ) return true ;
539
537
540
538
if ( testNamePatterns && ! testMatchesPattern ( this , testNamePatterns ) ) {
@@ -905,7 +903,7 @@ class Test extends AsyncResource {
905
903
// This helps catch any asynchronous activity that occurs after the tests
906
904
// have finished executing.
907
905
this . postRun ( ) ;
908
- } else if ( forceExit ) {
906
+ } else if ( this . harness ?. config . forceExit ) {
909
907
// This is the root test, and all known tests and hooks have finished
910
908
// executing. If the user wants to force exit the process regardless of
911
909
// any remaining ref'ed handles, then do that now. It is theoretically
@@ -1147,6 +1145,7 @@ class Suite extends Test {
1147
1145
constructor ( options ) {
1148
1146
super ( options ) ;
1149
1147
1148
+ const { testNamePatterns, testSkipPatterns, testOnlyFlag } = this . root ?. harness ?. config || { } ;
1150
1149
if ( testNamePatterns !== null && testSkipPatterns !== null && ! options . skip ) {
1151
1150
this . fn = options . fn || this . fn ;
1152
1151
this . skipped = false ;
@@ -1175,6 +1174,7 @@ class Suite extends Test {
1175
1174
}
1176
1175
1177
1176
postBuild ( ) {
1177
+ const { testNamePatterns, testSkipPatterns, testOnlyFlag } = this . root ?. harness ?. config || { } ;
1178
1178
this . buildPhaseFinished = true ;
1179
1179
if ( this . filtered && this . filteredSubtestCount !== this . subtests . length ) {
1180
1180
// A suite can transition from filtered to unfiltered based on the
0 commit comments