diff --git a/CHANGELOG.md b/CHANGELOG.md index cbe103308c3d..73151d8cd523 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ - `[jest-runtime, jest-transform]` share `cacheFS` between runtime and transformer ([#10901](https://github.com/facebook/jest/pull/10901)) - `[jest-transform]` Pass config options defined in Jest's config to transformer's `process` and `getCacheKey` functions ([#10926](https://github.com/facebook/jest/pull/10926)) - `[jest-worker]` Add support for custom task queues and adds a `PriorityQueue` implementation. ([#10921](https://github.com/facebook/jest/pull/10921)) +- `[jest-worker]` [**BREAKING**] Default to advanced serialization when using child process workers ([#10983] (https://github.com/facebook/jest/pull/10983)) ### Fixes diff --git a/packages/jest-worker/README.md b/packages/jest-worker/README.md index 085a8c4797df..4ba6391a511c 100644 --- a/packages/jest-worker/README.md +++ b/packages/jest-worker/README.md @@ -69,7 +69,7 @@ Maximum amount of times that a dead child can be re-spawned, per call. Defaults #### `forkOptions: Object` (optional) -Allow customizing all options passed to `childProcess.fork`. By default, some values are set (`cwd`, `env` and `execArgv`), but you can override them and customize the rest. For a list of valid values, check [the Node documentation](https://nodejs.org/api/child_process.html#child_process_child_process_fork_modulepath_args_options). +Allow customizing all options passed to `childProcess.fork`. By default, some values are set (`cwd`, `env`, `execArgv` and `serialization`), but you can override them and customize the rest. For a list of valid values, check [the Node documentation](https://nodejs.org/api/child_process.html#child_process_child_process_fork_modulepath_args_options). #### `computeWorkerKey: (method: string, ...args: Array) => ?string` (optional) diff --git a/packages/jest-worker/src/workers/ChildProcessWorker.ts b/packages/jest-worker/src/workers/ChildProcessWorker.ts index 6b7daa4758f2..33b57a1457b6 100644 --- a/packages/jest-worker/src/workers/ChildProcessWorker.ts +++ b/packages/jest-worker/src/workers/ChildProcessWorker.ts @@ -92,6 +92,9 @@ export default class ChildProcessWorker implements WorkerInterface { } as NodeJS.ProcessEnv, // Suppress --debug / --inspect flags while preserving others (like --harmony). execArgv: process.execArgv.filter(v => !/^--(debug|inspect)/.test(v)), + // default to advanced serialization in order to match worker threads + // @ts-expect-error: option does not exist on the node 10 types + serialization: 'advanced', silent: true, ...this._options.forkOptions, }); diff --git a/packages/jest-worker/src/workers/__tests__/ChildProcessWorker.test.js b/packages/jest-worker/src/workers/__tests__/ChildProcessWorker.test.js index e5e7e1e99694..1caa8e654380 100644 --- a/packages/jest-worker/src/workers/__tests__/ChildProcessWorker.test.js +++ b/packages/jest-worker/src/workers/__tests__/ChildProcessWorker.test.js @@ -70,6 +70,7 @@ it('passes fork options down to child_process.fork, adding the defaults', () => env: {...process.env, FORCE_COLOR: supportsColor.stdout ? '1' : undefined}, // Default option. execArgv: ['-p'], // Filtered option. execPath: 'hello', // Added option. + serialization: 'advanced', // Default option. silent: true, // Default option. }); });