Skip to content

Instantly share code, notes, and snippets.

@johinsDev
Last active September 11, 2019 21:10
Show Gist options
  • Select an option

  • Save johinsDev/79cf7b4ec07e7c31bc4dd938e2f208f3 to your computer and use it in GitHub Desktop.

Select an option

Save johinsDev/79cf7b4ec07e7c31bc4dd938e2f208f3 to your computer and use it in GitHub Desktop.
TEST React native Config with expo/typescript/react-native-testing-library
yarn add -D react-dom @testing-library/react-native @types/jest jest react-test-renderer @types/react-test-renderer jest-expo ts-jest
const { defaults: tsJestConfig } = require('ts-jest/presets')
const jestPreset = require('@testing-library/react-native/jest-preset')
module.exports = {
...tsJestConfig,
...jestPreset,
preset: 'jest-expo',
transformIgnorePatterns: [
'node_modules/(?!(jest-)?react-native|react-clone-referenced-element|@react-native-community|expo(nent)?|@expo(nent)?/.*|react-navigation|@react-navigation/.*|@unimodules/.*|sentry-expo|native-base)'
],
transform: {
...tsJestConfig.transform,
'\\.js$': '<rootDir>/node_modules/react-native/jest/preprocessor.js'
},
globals: {
'ts-jest': {
babelConfig: false,
tsConfig: './tsconfig.jest.json'
}
},
modulePaths: ['<rootDir>'],
setupFilesAfterEnv: ['@testing-library/react-native/cleanup-after-each']
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment