Skip to content

Conversation

@jaysoo
Copy link
Member

@jaysoo jaysoo commented Nov 28, 2025

Current Behavior

On Node.js v24+, the @nx/jest/plugin sets --no-experimental-strip-types in NODE_OPTIONS which causes an error: "node: --no-experimental-strip-types is not allowed in NODE_OPTIONS".

Additionally, jest.config.ts files using ESM syntax (export default, import) fail to load correctly under Node.js type-stripping when the project is configured for CommonJS.

Expected Behavior

  • Remove the NODE_OPTIONS manipulation that adds --no-experimental-strip-types
  • Add a migration (22.2.0-beta.2) that converts jest.config.ts files from ESM to CJS syntax for projects using @nx/jest/plugin
  • The migration only runs when @nx/jest/plugin is registered in nx.json
  • Projects with type: module are warned as they're incompatible with the plugin
  • Files using ESM-only features (import.meta, top-level await) are skipped with a warning for manual conversion

Demo

https://www.loom.com/share/8a157a0b01d144ae8d6ae48b9b0cd0e4

Related Issue(s)

Closes NXC-3541

@jaysoo jaysoo requested a review from a team as a code owner November 28, 2025 17:04
@jaysoo jaysoo requested a review from AgentEnder November 28, 2025 17:04
@vercel
Copy link

vercel bot commented Nov 28, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Updated (UTC)
nx-dev Ready Ready Preview Dec 1, 2025 2:19pm

@netlify
Copy link

netlify bot commented Nov 28, 2025

Deploy Preview for nx-docs ready!

Name Link
🔨 Latest commit 6ae1a0a
🔍 Latest deploy log https://app.netlify.com/projects/nx-docs/deploys/692da3283c80d300080b5573
😎 Deploy Preview https://deploy-preview-33657--nx-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

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

@nx-cloud
Copy link
Contributor

nx-cloud bot commented Nov 28, 2025

View your CI Pipeline Execution ↗ for commit 6ae1a0a

Command Status Duration Result
nx affected --targets=lint,test,test-kt,build,e... ✅ Succeeded 21m 52s View ↗
nx run-many -t check-imports check-lock-files c... ✅ Succeeded 2m 38s View ↗
nx-cloud record -- nx-cloud conformance:check ✅ Succeeded 12s View ↗
nx-cloud record -- nx format:check ✅ Succeeded 2s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded <1s View ↗

☁️ Nx Cloud last updated this comment at 2025-12-01 14:41:44 UTC

@jaysoo jaysoo changed the title fix(testing): remove --no-experimental-strip-types flag and add CJS mgration fix(testing): remove --no-experimental-strip-types flag for @nx/jest/plugin and migrate to jest.config.cts if necessary Nov 28, 2025
@jaysoo jaysoo changed the title fix(testing): remove --no-experimental-strip-types flag for @nx/jest/plugin and migrate to jest.config.cts if necessary fix(testing): remove --no-experimental-strip-types flag from @nx/jest/plugin + migrate to jest.config.cts if needed Nov 28, 2025
…/plugin + migrate to jest.config.cts if needed

On Node.js v24+, the `@nx/jest/plugin` sets `--no-experimental-strip-types` in
NODE_OPTIONS which causes an error: "node: --no-experimental-strip-types is not
allowed in NODE_OPTIONS".

Additionally, `jest.config.ts` files using ESM syntax (`export default`,
`import`) fail to load correctly under Node.js type-stripping when the project
is configured for CommonJS.

- Remove the NODE_OPTIONS manipulation that adds `--no-experimental-strip-types`
- Add a migration (22.2.0-beta.2) that converts `jest.config.ts` files from ESM
  to CJS syntax for projects using `@nx/jest/plugin`
- The migration only runs when `@nx/jest/plugin` is registered in `nx.json`
- Projects with `type: module` are warned as they're incompatible with the plugin
- Files using ESM-only features (import.meta, top-level await) are skipped with
  a warning for manual conversion

Fixes NXC-3541

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Copy link
Contributor

@nx-cloud nx-cloud bot left a comment

Choose a reason for hiding this comment

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

Nx Cloud has identified a flaky task in your failed CI:

🔂 Since the failure was identified as flaky, we reran your CI automatically.

Nx Cloud View detailed reasoning in Nx Cloud ↗


🎓 Learn more about Self-Healing CI on nx.dev

Comment on lines 140 to 145
if (
parent.kind === require('typescript').SyntaxKind.FunctionDeclaration ||
parent.kind === require('typescript').SyntaxKind.FunctionExpression ||
parent.kind === require('typescript').SyntaxKind.ArrowFunction ||
parent.kind === require('typescript').SyntaxKind.MethodDeclaration
) {
Copy link
Member

Choose a reason for hiding this comment

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

nit: we could use ts.isFunctionLike(parent)

@jaysoo jaysoo merged commit 731aba3 into master Dec 1, 2025
20 checks passed
@jaysoo jaysoo deleted the NXC-3541 branch December 1, 2025 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants