설치

npm i -D jest typescript ts-jest

jest와 typescript를 미리 설치해주어야 한다. (duh...)

세팅

npx ts-jest config:init

jest를 typescript로 사용할 수 있는 config 파일이 자동으로 생성된다.

사용

jest

// package.json에 설정이 되어있을 경우
npm test
npm t

일반 Jest를 사용하는 것과 방법이 동일하다. 위의 jest.config.js를 이용해서 Jest가 자동으로 typescript 모드로 구동된다.

장점

Reference

ts-jest