1
1
import type { TestResult } from '@jest/test-result' ;
2
- import {
3
- CallbackTestRunner ,
2
+ import type {
3
+ CallbackTestRunnerInterface ,
4
+ Config ,
4
5
OnTestFailure ,
5
6
OnTestStart ,
6
7
OnTestSuccess ,
@@ -32,8 +33,14 @@ export default function createRunner<
32
33
> (
33
34
runPath : string ,
34
35
{ getExtraOptions } : CreateRunnerOptions < ExtraOptions > = { } ,
35
- ) : typeof CallbackTestRunner {
36
- return class BaseTestRunner extends CallbackTestRunner {
36
+ ) {
37
+ return class BaseTestRunner implements CallbackTestRunnerInterface {
38
+ #globalConfig: Config . GlobalConfig ;
39
+
40
+ constructor ( globalConfig : Config . GlobalConfig ) {
41
+ this . #globalConfig = globalConfig ;
42
+ }
43
+
37
44
runTests (
38
45
tests : Array < Test > ,
39
46
watcher : TestWatcher ,
@@ -84,7 +91,7 @@ export default function createRunner<
84
91
const runner = require ( runPath ) ;
85
92
const baseOptions = {
86
93
config : test . context . config ,
87
- globalConfig : this . _globalConfig ,
94
+ globalConfig : this . #globalConfig ,
88
95
testPath : test . path ,
89
96
rawModuleMap : watcher . isWatchMode ( )
90
97
? test . context . moduleMap . getRawModuleMap ( )
@@ -118,13 +125,13 @@ export default function createRunner<
118
125
) : Promise < void > {
119
126
const worker = new Worker ( runPath , {
120
127
exposedMethods : [ 'default' ] ,
121
- numWorkers : this . _globalConfig . maxWorkers ,
128
+ numWorkers : this . #globalConfig . maxWorkers ,
122
129
forkOptions : { stdio : 'inherit' } ,
123
130
} ) as JestWorkerFarm < {
124
131
default : ( runTestOptions : RunTestOptions ) => TestResult ;
125
132
} > ;
126
133
127
- const mutex = throat ( this . _globalConfig . maxWorkers ) ;
134
+ const mutex = throat ( this . #globalConfig . maxWorkers ) ;
128
135
129
136
const runTestInWorker = ( test : Test ) =>
130
137
mutex ( ( ) => {
@@ -135,7 +142,7 @@ export default function createRunner<
135
142
return onStart ( test ) . then ( ( ) => {
136
143
const runTestOptions : RunTestOptions = {
137
144
config : test . context . config ,
138
- globalConfig : this . _globalConfig ,
145
+ globalConfig : this . #globalConfig ,
139
146
testPath : test . path ,
140
147
rawModuleMap : watcher . isWatchMode ( )
141
148
? test . context . moduleMap . getRawModuleMap ( )
0 commit comments