A preset that can be used to quickly get up and running with jest + typescript.
yarn add jest ts-jest typescript jest-preset-typescript --dev
or with npm
if that's more your style 😎
npm install jest ts-jest typescript jest-preset-typescript --save-dev
(note: if you already have the peer dependencies installed, you only need to install jest-preset-typescript
!)
Then, once all dependencies are installed, simply create a jest.config.js
in the root of your project with the following contents:
module.exports = {
preset: 'jest-preset-typescript'
};
All of the features come courtesy of ts-jest, so simply add this preset and you can author your tests/mocks/etc. in TypeScript, all the while getting the excellent testing capabilities of jest. 🎉