2

I'm using TypeScript, ESM, npm, and ts-jest. Unfortunately, it seems that transformIgnorePatterns isn't working.

I've tried multiple configurations, but nothing has helped me run Jest with ts-jest successfully. The only workaround that worked was replacing imports with require directly in node_modules, but that's not a viable final solution.

the error is: logs

My package.json has "type": "module". I'm using npm workspaces, my setup in the root is very similar to the one in my child package:

jest.config.ts

export default {
  preset: 'ts-jest/presets/default-esm',
  testEnvironment: 'node',
  testMatch: ['**/*.spec.ts'],
  transform: {
    '^.+\\.tsx?$': ['ts-jest']
  },
  transformIgnorePatterns: ['/node_modules/(?!log-symbols|picocolors)']
};

ts.config.json

{
    "compilerOptions": {
        "target": "ES2022",
        "module": "ESNext",
        "moduleResolution": "node",
        "declaration": true,
        "strict": true,
        "incremental": true,
        "esModuleInterop": true,
        "skipLibCheck": true,
        "forceConsistentCasingInFileNames": true,
        "composite": true,
        "types": ["node", "jest"],
        "allowImportingTsExtensions": true,
        "allowJs": true,
        "noEmit": true,
    },
    "ts-node": {
        "esm": true
    },
    "exclude": ["node_modules"]
}

I've tried various configurations with transformIgnorePatterns, target, and module values. The issue occurs not only with picocolors but also with chalk (versions 5 and 4).

1 Answer 1

0

I didn't come up with a valid solution. In the end, I decided to stop using log-symbols, and I chose picocolors instead of chalk.

For piccolors It works without transformIgnorePatterns

For piccolors It works even withhout transformIgnorePatterns

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.