@@ -27,6 +27,11 @@ jest.mock('os', () => {
27
27
let workerTransform ;
28
28
let workerEnd ;
29
29
30
+ const ENABLE_WORKER_THREADS =
31
+ typeof process . env . ENABLE_WORKER_THREADS !== 'undefined'
32
+ ? process . env . ENABLE_WORKER_THREADS === 'true'
33
+ : true ;
34
+
30
35
jest . mock ( 'jest-worker' , ( ) => {
31
36
return jest . fn ( ) . mockImplementation ( ( workerPath ) => {
32
37
return {
@@ -67,6 +72,7 @@ describe('parallel option', () => {
67
72
68
73
expect ( Worker ) . toHaveBeenCalledTimes ( 1 ) ;
69
74
expect ( Worker ) . toHaveBeenLastCalledWith ( workerPath , {
75
+ enableWorkerThreads : ENABLE_WORKER_THREADS ,
70
76
numWorkers : os . cpus ( ) . length - 1 ,
71
77
} ) ;
72
78
expect ( workerTransform ) . toHaveBeenCalledTimes (
@@ -98,6 +104,7 @@ describe('parallel option', () => {
98
104
99
105
expect ( Worker ) . toHaveBeenCalledTimes ( 1 ) ;
100
106
expect ( Worker ) . toHaveBeenLastCalledWith ( workerPath , {
107
+ enableWorkerThreads : ENABLE_WORKER_THREADS ,
101
108
numWorkers : Math . min ( 4 , os . cpus ( ) . length - 1 ) ,
102
109
} ) ;
103
110
expect ( workerTransform ) . toHaveBeenCalledTimes (
@@ -117,6 +124,7 @@ describe('parallel option', () => {
117
124
118
125
expect ( Worker ) . toHaveBeenCalledTimes ( 1 ) ;
119
126
expect ( Worker ) . toHaveBeenLastCalledWith ( workerPath , {
127
+ enableWorkerThreads : ENABLE_WORKER_THREADS ,
120
128
numWorkers : 2 ,
121
129
} ) ;
122
130
expect ( workerTransform ) . toHaveBeenCalledTimes (
@@ -140,6 +148,7 @@ describe('parallel option', () => {
140
148
141
149
expect ( Worker ) . toHaveBeenCalledTimes ( 1 ) ;
142
150
expect ( Worker ) . toHaveBeenLastCalledWith ( workerPath , {
151
+ enableWorkerThreads : ENABLE_WORKER_THREADS ,
143
152
numWorkers : Math . min ( 1 , os . cpus ( ) . length - 1 ) ,
144
153
} ) ;
145
154
expect ( workerTransform ) . toHaveBeenCalledTimes (
@@ -167,6 +176,7 @@ describe('parallel option', () => {
167
176
168
177
expect ( Worker ) . toHaveBeenCalledTimes ( 1 ) ;
169
178
expect ( Worker ) . toHaveBeenLastCalledWith ( workerPath , {
179
+ enableWorkerThreads : ENABLE_WORKER_THREADS ,
170
180
numWorkers : Math . min ( Object . keys ( entries ) . length , os . cpus ( ) . length - 1 ) ,
171
181
} ) ;
172
182
expect ( workerTransform ) . toHaveBeenCalledTimes (
@@ -194,6 +204,7 @@ describe('parallel option', () => {
194
204
195
205
expect ( Worker ) . toHaveBeenCalledTimes ( 1 ) ;
196
206
expect ( Worker ) . toHaveBeenLastCalledWith ( workerPath , {
207
+ enableWorkerThreads : ENABLE_WORKER_THREADS ,
197
208
numWorkers : Math . min ( Object . keys ( entries ) . length , os . cpus ( ) . length - 1 ) ,
198
209
} ) ;
199
210
expect ( workerTransform ) . toHaveBeenCalledTimes (
@@ -232,6 +243,7 @@ describe('parallel option', () => {
232
243
233
244
expect ( Worker ) . toHaveBeenCalledTimes ( 1 ) ;
234
245
expect ( Worker ) . toHaveBeenLastCalledWith ( workerPath , {
246
+ enableWorkerThreads : ENABLE_WORKER_THREADS ,
235
247
numWorkers : Math . min ( Object . keys ( entries ) . length , os . cpus ( ) . length - 1 ) ,
236
248
} ) ;
237
249
expect ( workerTransform ) . toHaveBeenCalledTimes (
0 commit comments