API Reference

ts-jest

Jest transformer that compiles TypeScript on the fly, enabling type-aware tests without a separate build step.

Official Documentation ↗
CompatibilityThis documentation covers version v30.5.2. Check the official docs for the latest API surface.

Installation

npmnpm install --save-dev jest ts-jest typescript
pnpmpnpm add -D jest ts-jest typescript

Methods

Overview

ts-jest is a Jest transformer that compiles TypeScript on the fly so tests can run without a separate build step. This reference lists the most frequently used APIs with accurate signatures and runnable snippets.

Core APIs

  • preset — Jest config preset that wires the TypeScript transform and default test globs.
  • createTransformer — Builds a transformer instance for use in a custom Jest transform entry.
  • diagnostics — Controls whether TypeScript diagnostics fail the test run or only warn.

Example

// jest.config.js
module.exports = {
  preset: 'ts-jest',
  testEnvironment: 'node',
};

Notes

Type checking during tests can slow suites; isolatedModules trades type safety in tests for speed, so pair it with an explicit tsc check.

Verification

Run a TypeScript test file through Jest with the preset and confirm it executes without a prior compile step.

API reference evidence

Fetched from official sources on 2026-11-08T20:06:00+08:00 via WebFetch https://kulshekhar.github.io/ts-jest/docs/getting-started/options/diagnostics;WebFetch https://kulshekhar.github.io/ts-jest/docs/getting-started/presets;WebFetch https://cdn.jsdelivr.net/npm/ts-jest@latest/dist/index.d.ts.

FAQ

Why do tests fail with type errors that the build ignores?
ts-jest type-checks files it transforms; set diagnostics.warnOnly to true or fix the reported codes.
How do I speed up the transform?
Enable isolatedModules to skip full type checking during tests, and rely on a separate tsc run for types.
How do I use a specific tsconfig?
Point ts-jest at it through the tsconfig transform option, for example tsconfig: "tsconfig.test.json".