From e5055da745365cc495490b3b695e7b1d91c26728 Mon Sep 17 00:00:00 2001 From: Dan Bornstein Date: Mon, 20 May 2024 16:10:33 -0700 Subject: [PATCH 1/2] Add a section for runner options, commented out. --- src/jest.config.mjs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/jest.config.mjs b/src/jest.config.mjs index 866a2be8a..7c6c2e920 100644 --- a/src/jest.config.mjs +++ b/src/jest.config.mjs @@ -76,5 +76,11 @@ export default { `${TESTER_DIR}/lib/node_modules/jest-extended/all`, `${TESTER_DIR}/lib/code/node_modules/@this/main-tester` ] + }, + + // Test harness options. + ...{ + // maxConcurrency: 1, + // maxWorkers: 1 } }; From 31111c73001c34551d097caa2caf878c5c0b7ee7 Mon Sep 17 00:00:00 2001 From: Dan Bornstein Date: Mon, 20 May 2024 16:11:12 -0700 Subject: [PATCH 2/2] Add a workaround for the Jest `process.emit()` binding bug. --- src/main-tester/index.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main-tester/index.js b/src/main-tester/index.js index cad915f12..06fd49f44 100644 --- a/src/main-tester/index.js +++ b/src/main-tester/index.js @@ -12,3 +12,14 @@ process.on('warning', (warning) => { console.log('%s: %s\n', warning.name, warning.message); }); + +// This works around a bug in Jest's wrapping of `process`: `process.emit` is +// normally inherited from `EventEmitter`, but `source-map-support` directly +// adds an `emit` binding to `process`. _Sometimes_ this happens when Jest is in +// the middle of creating a `SyntheticModule` wrapper for `process`, and if that +// happens at just the wrong time, Node will throw `ReferenceError: Export +// 'emit' is not defined in module`. By putting a direct binding of +// `process.emit` here, we avoid the race (though there is still arguably an +// underlying problem). See this issue in Jest: +// +process.emit = process.emit; // eslint-disable-line no-self-assign