Using with React Native

To use ts-jest with React Native + TypeScript and Babel 7, you’ll first need to follow this tutorial.

After that, some little modifications will be required as follows:

Babel config

If you didn’t yet, move any Babel config from .babelrc to babel.config.js. It should at least contain:

// babel.config.js
module.exports = {
  presets: [
    'module:metro-react-native-babel-preset'
  ]
};

Jest config

In the same way that you moved Babel config, move Jest config from jest key of package.json to jest.config.js. It should look like this:

// jest.config.js
const { defaults: tsjPreset } = require('ts-jest/presets');

module.exports = {
  ...tsjPreset,
  preset: 'react-native',
  transform: {
    ...tsjPreset.transform,
    '\\.js$': '<rootDir>/node_modules/react-native/jest/preprocessor.js',
  },
  globals: {
    'ts-jest': {
      babelConfig: true,
    }
  },
  // This is the only part which you can keep
  // from the above linked tutorial's config:
  cacheDirectory: '.jest/cache',
};