Skip to content

Instantly share code, notes, and snippets.

@nurdiansyah
Forked from DimitryDushkin/configs.js
Created December 30, 2019 21:53
Show Gist options
  • Save nurdiansyah/70e83540172abcd44cf03f3f524b0893 to your computer and use it in GitHub Desktop.
Save nurdiansyah/70e83540172abcd44cf03f3f524b0893 to your computer and use it in GitHub Desktop.
React Native 0.57 + Babel 7 + Typescript + Jest
// babel.config.js
module.exports = {
"presets": [
"module:metro-react-native-babel-preset",
],
"plugins": [
["module-resolver", {
"root": ["./src"],
"extensions": [".js", ".ts", ".tsx", ".ios.js", ".android.js"]
}],
"@babel/plugin-transform-runtime",
],
"env": {
"production": {
"plugins": ["transform-remove-console"]
},
}
}
// jest.config.js
module.exports = {
"preset": "react-native",
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"jsx",
"json"
],
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(js|ts)x?$",
"transform": {
"^.+\\.(js|tsx?)$": "<rootDir>/node_modules/react-native/jest/preprocessor.js",
},
"testPathIgnorePatterns": [
"\\.snap$",
"<rootDir>/node_modules/"
],
"cacheDirectory": ".jest/cache",
"transformIgnorePatterns": [
"node_modules/(?!(react-native|react-navigation|react-navigation-tabs|react-navigation-redux-helpers|react-native-safari-view|react-native-linear-gradient|react-native-blur|react-native-animatable|react-native-wkwebview-reborn|react-native-safe-area-view|react-native-popup-menu|redux-persist)/)"
],
"setupFiles": [
"./__mocks__/react-native.js"
],
};
// package.json
{
"name": "rn-app",
"version": "0.0.1",
"private": true,
"dependencies": {
"react": "16.5.1",
"react-native": "^0.57.1"
},
"devDependencies": {
"jest": "^23.6.0",
"metro-react-native-babel-preset": "^0.47.0",
"@babel/plugin-transform-runtime": "^7.1.0",
"babel-plugin-module-resolver": "^3.1.1",
"babel-plugin-transform-remove-console": "^6.9.4",
"react-native-mock-render": "^0.1.2",
"typescript": "^3.0.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment