Skip to content

[Bug]: ts-jest 29.2 breaks dependency transform #4473

@unional

Description

@unional

Version

29.2.3

Steps to reproduce

  1. clone https://github.com/repobuddy/repobuddy/tree/ts-jest-29.2-issue
  2. pnpm i
  3. pnpm build
  4. pnpm jest test

Expected behavior

test pass

Actual behavior

    /home/runner/work/repobuddy/repobuddy/packages/jest/ts/tests/chalk.spec.ts:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,jest){import { it } from '@jest/globals';
                                                                                      ^^^^^^

    SyntaxError: Cannot use import statement outside a module

      at Runtime.createScriptFromCode (../../node_modules/.pnpm/[email protected]/node_modules/jest-runtime/build/index.js:1505:14)

Debug log

see above

Additional context

It is working with ts-jest 29.1

the transform config is:

  transform: {
    '^.+\\.(ts|tsx|cts|mts)$': ['ts-jest', [{
      isolatedModules: true,
      useESM: true,
    }]],
    '\\.m?jsx?$': 'jest-esm-transformer-2'
  },
  transformIgnorePatterns: [],

I have also tried to use transformIgnorePatterns but also not working.

Environment

System:
    OS: macOS 14.5
    CPU: (10) arm64 Apple M1 Pro
  Binaries:
    Node: 20.12.2 - ~/.nvm/versions/node/v20.12.2/bin/node
    npm: 10.5.0 - ~/.nvm/versions/node/v20.12.2/bin/npm
    pnpm: 9.5.0 - ~/.nvm/versions/node/v20.12.2/bin/pnpm
    bun: 0.1.6 - ~/.bun/bin/bun
  npmPackages:
    jest: ^29.7.0 => 29.7.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions