Skip to content

fix(nextjs): use next/jest.js for Jest configuration to support modern JSX transform #31705

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 24, 2025

Conversation

jaysoo
Copy link
Member

@jaysoo jaysoo commented Jun 24, 2025

This PR fixes and issue with Next.js + Jest to remove warnings about outdated transforms.

Changes Made

  • Updated Next.js application generator to use next/jest.js instead of manual babel-jest configuration
  • Updated Next.js library generator to use the same modern configuration approach
  • Added e2e tests to verify the new Jest configuration works correctly
  • Kept same CJS vs ESM logic for JS vs TS config (existing behavior)

Current Behavior

When using React 19 with Next.js applications in Nx, developers receive a warning about outdated JSX transform because the Jest configuration uses
manual babel-jest setup instead of Next.js's recommended approach.

Expected Behavior

Next.js applications and libraries generated by Nx should use next/jest.js configuration which automatically handles the modern JSX transform
(runtime: 'automatic') and provides proper Jest setup for Next.js projects without warnings.

Related Issue(s)

Fixes #27900

@jaysoo jaysoo requested a review from a team as a code owner June 24, 2025 15:39
@jaysoo jaysoo requested a review from mandarini June 24, 2025 15:39
Copy link

vercel bot commented Jun 24, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
nx-dev ✅ Ready (Inspect) Visit Preview Jun 24, 2025 6:53pm

Copy link

nx-cloud bot commented Jun 24, 2025

View your CI Pipeline Execution ↗ for commit 2545fdc.

Command Status Duration Result
nx affected --targets=lint,test,build,e2e,e2e-c... ✅ Succeeded 19m 24s View ↗
nx run-many -t check-imports check-commit check... ✅ Succeeded 18s View ↗
nx-cloud record -- nx-cloud conformance:check ✅ Succeeded 2s View ↗
nx-cloud record -- nx format:check ✅ Succeeded 4s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded 3s View ↗
nx documentation ✅ Succeeded 36s View ↗

☁️ Nx Cloud last updated this comment at 2025-06-24 19:06:35 UTC

@jaysoo jaysoo force-pushed the fix/nextjs-jest-jsx-transform-27900-main branch from 008d254 to 45338ae Compare June 24, 2025 15:42
@jaysoo jaysoo force-pushed the fix/nextjs-jest-jsx-transform-27900-main branch 3 times, most recently from 4334191 to c724393 Compare June 24, 2025 16:02
@jaysoo jaysoo force-pushed the fix/nextjs-jest-jsx-transform-27900-main branch from c724393 to 97cc99c Compare June 24, 2025 17:34
@jaysoo jaysoo force-pushed the fix/nextjs-jest-jsx-transform-27900-main branch 2 times, most recently from b8595ef to a4857d3 Compare June 24, 2025 18:03
@jaysoo jaysoo force-pushed the fix/nextjs-jest-jsx-transform-27900-main branch from a4857d3 to 2545fdc Compare June 24, 2025 18:39
@jaysoo jaysoo merged commit 13da36e into master Jun 24, 2025
7 checks passed
@jaysoo jaysoo deleted the fix/nextjs-jest-jsx-transform-27900-main branch June 24, 2025 19:09
Copy link

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 30, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Warning about outdated JSX transform being used for Next.js apps with React 19
2 participants