docs(guide): document native ESM support for Jest 30.4.2+ - #3957
Conversation
✅ Deploy Preview for fakerjs ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## next #3957 +/- ##
=======================================
Coverage 98.91% 98.91%
=======================================
Files 924 924
Lines 3224 3224
Branches 585 567 -18
=======================================
Hits 3189 3189
Misses 31 31
Partials 4 4 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR updates the v10 upgrade guide to clarify how to run Jest against Faker v10 (ESM-only) using Jest’s native ESM support in newer Jest versions, reducing the need for older transform-based workarounds.
Changes:
- Documented a Jest
>=30.4.2path usingNODE_OPTIONS="--experimental-vm-modules"and linking to Jest’s ESM docs. - Added a note that CJS
require-based test files additionally need Node.js>=24.9due to Jest’s synchronousvmAPIs.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ST-DDT
left a comment
There was a problem hiding this comment.
Thanks for your contribution ❤️
I think after adressing the version comment this is good to go.
xDivisionByZerox
left a comment
There was a problem hiding this comment.
Works for me. @faker-js/members can we can an implementation of this jn the playground to verify that this actually works (and keeps working) before we merge this?
fc63b1c
|
Done, changed it to v24.9.0. |
Adds the Jest section you suggested in #3606 — that with Jest >=30.4.2 the transformIgnorePatterns workaround isn't needed anymore, just
NODE_OPTIONS="--experimental-vm-modules", with a link to Jest's ESM docs.One detail I hit while double-checking your recipe before writing it down: for require-based CJS test files this also needs Node >=24.9 — on Node 22, Jest 30.4.2 fails with "Jest's require(ESM) requires Node v24.9+ for synchronous vm module APIs". Since Faker v10 still supports Node 20/22 per engines, I added a sentence about that so people on supported-but-older Node versions aren't left confused. Verified both ways in a scratch project: Node 24.18 + the flag passes a plain
require('@faker-js/faker')test with zero transform config, Node 22 + the flag fails with that exact message, and no flag at all gives the classic SyntaxError.Left the ts-jest workaround section untouched for older Jest versions. Prettier passes on the file.
Closes #3606 if you feel this covers it.