Skip to content

Latest commit

 

History

History
93 lines (80 loc) · 3.79 KB

options.md

File metadata and controls

93 lines (80 loc) · 3.79 KB
id title
options
Options

Introduction

All ts-jest specific options can be defined in Jest transform config object in the package.json file of your project, or through a jest.config.js, or jest.config.ts file.

/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
  // [...]
  transform: {
    // '^.+\\.[tj]sx?$' to process js/ts with `ts-jest`
    // '^.+\\.m?[tj]sx?$' to process js/ts/mjs/mts with `ts-jest`
    '^.+\\.tsx?$': [
      'ts-jest',
      {
        // ts-jest configuration goes here
      },
    ],
  },
}
import type { JestConfigWithTsJest } from 'ts-jest'

const jestConfig: JestConfigWithTsJest = {
  // [...]
  transform: {
    // '^.+\\.[tj]sx?$' to process js/ts with `ts-jest`
    // '^.+\\.m?[tj]sx?$' to process js/ts/mjs/mts with `ts-jest`
    '^.+\\.tsx?$': [
      'ts-jest',
      {
        // ts-jest configuration goes here
      },
    ],
  },
}
{
  // [...]
  "jest": {
    "transform": {
      // '^.+\\.[tj]sx?$' to process js/ts with `ts-jest`
      // '^.+\\.m?[tj]sx?$' to process js/ts/mjs/mts with `ts-jest`
      "^.+\\.tsx?$": [
        "ts-jest",
        {
          // ts-jest configuration goes here
        }
      ]
    }
  }
}

:::important

When using TypeScript Jest config file, Jest will use ts-node to compile the config file. ts-jest doesn't take part in that process.

:::

Options

All options have default values which should fit most of the projects. Click on the option's name to see details and example(s).

Option Description Type Default
compiler TypeScript module to use as compiler. string "typescript"
tsconfig TypeScript compiler related configuration. string|object|boolean auto
isolatedModules Disable type-checking boolean disabled
astTransformers Custom TypeScript AST transformers object auto
diagnostics Diagnostics related configuration. boolean|object enabled
babelConfig Babel(Jest) related configuration. boolean|string|object disabled
stringifyContentPathRegex Files which will become modules returning self content. string|RegExp disabled
useESM Enable ESM support boolean auto