@@ -51,33 +51,36 @@ afterEach(() => {
5151 process . execArgv = originalExecArgv ;
5252} ) ;
5353
54- it ( 'passes fork options down to child_process.fork , adding the defaults' , ( ) => {
54+ it ( 'passes fork options down to worker_threads.Worker , adding the defaults' , ( ) => {
5555 const thread = require . resolve ( '../threadChild' ) ;
5656
5757 process . execArgv = [ '--inspect' , '-p' ] ;
5858
5959 // eslint-disable-next-line no-new
6060 new Worker ( {
6161 forkOptions : {
62- cwd : '/tmp' ,
6362 execPath : 'hello' ,
6463 } ,
6564 maxRetries : 3 ,
65+ workerData : {
66+ foo : 'bar' ,
67+ } ,
6668 workerId : process . env . JEST_WORKER_ID - 1 ,
6769 workerPath : '/tmp/foo/bar/baz.js' ,
6870 } ) ;
6971
7072 expect ( workerThreads . mock . calls [ 0 ] [ 0 ] ) . toBe ( thread . replace ( / \. t s $ / , '.js' ) ) ;
7173 expect ( workerThreads . mock . calls [ 0 ] [ 1 ] ) . toEqual ( {
74+ env : process . env , // Default option.
7275 eval : false ,
76+ execArgv : [ '--inspect' , '-p' ] ,
77+ execPath : 'hello' , // Added option.
78+ resourceLimits : undefined ,
7379 stderr : true ,
7480 stdout : true ,
7581 workerData : {
76- cwd : '/tmp' , // Overridden default option.
77- env : process . env , // Default option.
78- execArgv : [ '-p' ] , // Filtered option.
79- execPath : 'hello' , // Added option.
80- silent : true , // Default option.
82+ // Added option.
83+ foo : 'bar' ,
8184 } ,
8285 } ) ;
8386} ) ;
@@ -91,9 +94,7 @@ it('passes workerId to the thread and assign it to env.JEST_WORKER_ID', () => {
9194 workerPath : '/tmp/foo' ,
9295 } ) ;
9396
94- expect ( workerThreads . mock . calls [ 0 ] [ 1 ] . workerData . env . JEST_WORKER_ID ) . toEqual (
95- '3' ,
96- ) ;
97+ expect ( workerThreads . mock . calls [ 0 ] [ 1 ] . env . JEST_WORKER_ID ) . toEqual ( '3' ) ;
9798} ) ;
9899
99100it ( 'initializes the thread with the given workerPath' , ( ) => {
0 commit comments