Skip to content

docs(guide): document native ESM support for Jest 30.4.2+ - #3957

Merged
ST-DDT merged 3 commits into
faker-js:nextfrom
MahinAnowar:docs/jest-30-native-esm
Jul 26, 2026
Merged

ST-DDT merged 3 commits into
faker-js:nextfrom
MahinAnowar:docs/jest-30-native-esm

Conversation

@MahinAnowar

Copy link
Copy Markdown
Contributor

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.

@MahinAnowar
MahinAnowar requested a review from a team as a code owner July 19, 2026 09:11
@netlify

netlify Bot commented Jul 19, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for fakerjs ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit f7a0057
🔍 Latest deploy log https://app.netlify.com/projects/fakerjs/deploys/6a5f4ff2a66c520008734db0
😎 Deploy Preview https://deploy-preview-3957.fakerjs.dev
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@codecov

codecov Bot commented Jul 19, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.91%. Comparing base (974490f) to head (f7a0057).

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:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
@ST-DDT
ST-DDT requested a review from Copilot July 19, 2026 09:14
@ST-DDT ST-DDT added c: docs Improvements or additions to documentation p: 1-normal Nothing urgent s: pending triage Pending Triage labels Jul 19, 2026
@ST-DDT ST-DDT added this to the v10.x milestone Jul 19, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.2 path using NODE_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.9 due to Jest’s synchronous vm APIs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread docs/guide/upgrading.md Outdated
ST-DDT
ST-DDT previously approved these changes Jul 19, 2026

@ST-DDT ST-DDT left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution ❤️
I think after adressing the version comment this is good to go.

@ST-DDT ST-DDT removed the s: pending triage Pending Triage label Jul 19, 2026
Shinigami92
Shinigami92 previously approved these changes Jul 19, 2026

@xDivisionByZerox xDivisionByZerox left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

@MahinAnowar

Copy link
Copy Markdown
Contributor Author

Done, changed it to v24.9.0.

@ST-DDT
ST-DDT added this pull request to the merge queue Jul 26, 2026
Merged via the queue into faker-js:next with commit 717fa14 Jul 26, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c: docs Improvements or additions to documentation p: 1-normal Nothing urgent

5 participants