-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add a script to patch jest-worker for bigint assertion messages
- Loading branch information
1 parent
7cb9fee
commit b5de5d8
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// See https://github.com/facebook/jest/issues/11617 | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
const pathToMessageParentJs = path.join(__dirname, '../node_modules/jest-worker/build/workers/messageParent.js'); | ||
|
||
const originalContents = fs.readFileSync(pathToMessageParentJs).toString(); | ||
const patch = `try { | ||
parentProcess.send([_types().PARENT_MESSAGE_CUSTOM, message]); | ||
} catch (error) { | ||
console.error('jest-worker message serialisation failed', error); | ||
console.dir(message, {depth: 10}); | ||
throw error; | ||
}`; | ||
|
||
if (originalContents.includes(patch)) { | ||
console.log(pathToMessageParentJs, 'is already patched, nothing to do...'); | ||
} else { | ||
const patchedContents = originalContents.replace( | ||
'parentProcess.send([_types().PARENT_MESSAGE_CUSTOM, message]);', | ||
patch | ||
); | ||
|
||
fs.writeFileSync(pathToMessageParentJs, patchedContents); | ||
console.log(pathToMessageParentJs, 'successfully patched!'); | ||
} |