Skip to content

Commit

Permalink
Make jest react-native preset to use typescript files (#22217)
Browse files Browse the repository at this point in the history
Summary:
Metro and react-native now have first-class support to Typescript with Babel 7, but react-native Jest preset needs specific settings to work with .ts and .tsx files.
This PR updates react-native Jest preset to use Typescript out of the box.
Pull Request resolved: #22217

Differential Revision: D13396206

Pulled By: cpojer

fbshipit-source-id: aa4e4163e555c6b213457755bc13432fa1cddf5e
  • Loading branch information
dalcib authored and facebook-github-bot committed Dec 10, 2018
1 parent 7fb0288 commit af3570c
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion jest-preset.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,31 @@
"react-native"
]
},
"moduleFileExtensions": [
"js",
"json",
"jsx",
"node",
"ts",
"tsx"
],
"moduleNameMapper": {
"^React$": "<rootDir>/node_modules/react"
},
"modulePathIgnorePatterns": [
"<rootDir>/node_modules/react-native/Libraries/react-native/"
],
"transform": {
"^.+\\.js$": "babel-jest",
"^.+\\.(js|ts|tsx)$": "babel-jest",
"^.+\\.(bmp|gif|jpg|jpeg|mp4|png|psd|svg|webp)$": "<rootDir>/node_modules/react-native/jest/assetFileTransformer.js"
},
"transformIgnorePatterns": [
"node_modules/(?!(jest-)?react-native|react-clone-referenced-element)"
],
"testMatch": [
"**/__tests__/**/*.(js|ts|tsx)",
"**/?(*.)+(spec|test).(js|ts|tsx)"
],
"setupFiles": [
"<rootDir>/node_modules/react-native/jest/setup.js"
],
Expand Down

0 comments on commit af3570c

Please sign in to comment.