Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
65 lines (40 sloc) 1.83 KB
Installing ts-jest

ts-jest is a Typescript preprocessor for Jest pre-processor. You'll need both Jest and TypeScript installed inside your project.

Tip: If you get an error with the following npm commands such as npx: command not found, you can replace npx XXX with node node_modules/.bin/XXX from the root of your project.


You can install ts-jest and dependencies all at once with the following commands.

Using `npm`:
npm install --save-dev jest typescript ts-jest @types/jest

Using yarn:

yarn add --dev jest typescript ts-jest @types/jest

Jest config file


By default Jest can run without any config files, but it will not compile .ts files. To make it transpile TypeScript with ts-jest, we will need to create a configuration file.

ts-jest can create the configuration file for you automatically:

Using npm:

npx ts-jest config:init

Using yarn:

yarn ts-jest config:init

This will create a basic Jest configuration file which will make Jest know about your .ts files and handle them correctly.

You can also use the jest --init command (prefixed with either npx or yarn depending on what you're using) to have more options related to Jest. However, answer no to the Jest question about whether or not to enable Typescript. Instead, add the line: preset: "ts-jest" to the jest.config.js file afterwards.


For customizing jest, please follow their official guide online.

ts-jest specific options can be found here.