发布

  • fix(testing): remove --no-experimental-strip-types flag from @nx/jest/plugin + migrate to jest.config.cts if needed (#33657)

    frostbyte_neo 发布于 2025-12-01 14:43:26 +00:00

    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


    Co-authored-by: Claude noreply@anthropic.com

    下载附件