{"id":10419,"library":"ts-jest","title":"ts-jest","description":"ts-jest is a Jest transformer with source map support that enables testing projects written in TypeScript using Jest. It supports all TypeScript features, including type-checking. The current stable version is 29.4.9. Note that ts-jest does not follow semantic versioning, which means major breaking changes can occur without a corresponding major version increment. Releases are frequent, primarily for patch updates.","status":"active","version":"29.4.9","language":"javascript","source_language":"en","source_url":"https://github.com/kulshekhar/ts-jest","tags":["javascript","jest","typescript","sourcemap","react","testing"],"install":[{"cmd":"npm install ts-jest","lang":"bash","label":"npm"},{"cmd":"yarn add ts-jest","lang":"bash","label":"yarn"},{"cmd":"pnpm add ts-jest","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[],"quickstart":{"code":"{\n  \"devDependencies\": {\n    \"jest\": \"^29.4.9\",\n    \"typescript\": \"^5.0.0\",\n    \"ts-jest\": \"^29.4.9\",\n    \"@types/jest\": \"^29.4.9\"\n  },\n  \"scripts\": {\n    \"test\": \"jest\"\n  }\n}\n\n// jest.config.ts (created by `npx ts-jest config:init`)\nexport default {\n  preset: 'ts-jest',\n  testEnvironment: 'node',\n  roots: ['<rootDir>/src'],\n};\n\n// src/sum.ts\nexport function sum(a: number, b: number): number {\n  return a + b;\n}\n\n// src/sum.test.ts\nimport { sum } from './sum';\n\ndescribe('sum', () => {\n  it('adds two numbers', () => {\n    expect(sum(1, 2)).toBe(3);\n  });\n});\n","lang":"typescript","description":"This quickstart shows how to set up `ts-jest` for a basic TypeScript project. It includes the necessary `package.json` dependencies and `scripts`, a minimal `jest.config.ts` (generated via `npx ts-jest config:init`), a simple TypeScript function, and its corresponding test file. After installation and configuration, tests can be run using `npm test`."},"warnings":[{"fix":"Always review the CHANGELOG.md before upgrading ts-jest, especially across minor versions, and thoroughly test your application after any update.","message":"ts-jest explicitly states it does not follow semantic versioning. This means breaking changes can occur in minor or even patch releases, making upgrades potentially risky.","severity":"breaking","affected_versions":">=23.10.0"},{"fix":"Ensure that your installed versions of `jest` (`^29.0.0 || ^30.0.0`) and `typescript` (`>=4.3 <7`) match the peer dependency range specified by ts-jest.","message":"ts-jest has strict peer dependency requirements for Jest and TypeScript versions. Incompatible versions can lead to unexpected errors or installation failures.","severity":"gotcha","affected_versions":">=29.0.0"},{"fix":"Choose the appropriate tool based on your project's needs. If you require full TypeScript type-checking during tests, `ts-jest` is the correct choice. If you only need fast transpilation without type checks, Babel might be preferred (though often used with other transformers).","message":"There's a fundamental difference between using `ts-jest` for TypeScript compilation and using Babel with `@babel/preset-typescript`. `ts-jest` handles type-checking and Jest integration, while Babel with `preset-typescript` only strips types, potentially missing type errors.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"last_verified":"2026-04-18T00:00:00.000Z","next_check":"2026-07-17T00:00:00.000Z","problems":[{"fix":"Add `preset: 'ts-jest'` to your Jest configuration file, for example: `export default { preset: 'ts-jest' };`","cause":"The Jest configuration file (`jest.config.js` or `jest.config.ts`) does not include `preset: 'ts-jest'`.","error":"Jest: ts-jest preset was not applied. Ensure that you have configured jest.config.js/ts to use a preset."},{"fix":"Install all necessary peer dependencies explicitly using `npm install -D jest typescript @types/jest ts-jest` (or `yarn add --dev ...`) and ensure their versions fall within the ranges specified by `ts-jest`.","cause":"A required peer dependency of `ts-jest` (like `typescript`, `jest`, `@jest/types`, `babel-jest`, etc.) is not installed or its version is incompatible.","error":"Cannot find module 'typescript' or 'jest' or '@jest/types'"},{"fix":"Verify that your `jest` and `typescript` versions satisfy `ts-jest`'s peer dependency requirements. Try clearing your `node_modules` and `npm cache clean --force` (or `yarn cache clean`), then reinstall dependencies.","cause":"This usually indicates an incompatibility between `ts-jest` and the installed version of Jest or TypeScript, or a corrupted `node_modules`.","error":"Error: Jest: a transformer must at least provide a `process` function."},{"fix":"Address the specific TypeScript errors in your source or test files. Ensure your `tsconfig.json` (especially `compilerOptions` like `target`, `module`, `strict`) is correctly configured for your project and `ts-jest`.","cause":"TypeScript compiler errors are being reported during the test run, indicating issues with your code's types or `tsconfig.json` configuration.","error":"TSxxxx: [TypeScript compilation error]"}],"ecosystem":"npm"}