I'm trying to run my test suite but I am getting the following error:
Couldn't find preset "module:metro-react-native-babel-preset" relative to directory "/Users/dan/Sites/X"
at node_modules/babel-core/lib/transformation/file/options/option-manager.js:293:19
at Array.map (<anonymous>)
at OptionManager.resolvePresets (node_modules/babel-core/lib/transformation/file/options/option-manager.js:275:20)
at OptionManager.mergePresets (node_modules/babel-core/lib/transformation/file/options/option-manager.js:264:10)
at OptionManager.mergeOptions (node_modules/babel-core/lib/transformation/file/options/option-manager.js:249:14)
at OptionManager.init (node_modules/babel-core/lib/transformation/file/options/option-manager.js:368:12)
at File.initOptions (node_modules/babel-core/lib/transformation/file/index.js:212:65)
at File.initOptions (node_modules/ts-jest/dist/util/hacks.js:23:43)
at new File (node_modules/babel-core/lib/transformation/file/index.js:135:24)
at Pipeline.transform (node_modules/babel-core/lib/transformation/pipeline.js:46:16)
Here's my jest
config in package.json
:
"jest": {
"preset": "react-native",
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"jsx",
"json"
],
"transform": {
"^.+\\.(js)$": "<rootDir>/node_modules/react-native/jest/preprocessor.js",
"\\.(ts|ts)x?$": "ts-jest"
},
"testRegex": "/src/.*.spec.(js|ts|tsx)?$",
"globals": {
"ts-jest": {
"useBabelrc": true
}
}
}
If needed, here's the contents of babelrc
{
"presets": ["module:metro-react-native-babel-preset"],
"plugins": [
[
"module-resolver",
{
"alias": {
"~": "./src"
}
}
]
]
}