score:2
Accepted answer
this is what solved the problem for me:
- first thing, install
yarn
. follow this link for instructions. - second, ensure your
package.json
looks something like this:
"dependencies": {
"@expo/vector-icons": "9.0.0",
"expo": "^32.0.0",
"prop-types": "15.6.2",
"react": "16.5.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-32.0.0.tar.gz",
...
},
"devdependencies": {
"babel-preset-expo": "^5.0.0",
"jest-expo": "^32.0.0",
...
}
"scripts": {
"test": "jest",
...
},
"jest": {
"preset": "jest-expo",
"transform": {
"^.+\\.js$": "babel-jest"
},
}
- third, ensure your
babel.config.js
is setup correctly. here's the one from my project running expo's sdk 32:
module.exports = function (api) {
api.cache(true);
return {
presets: [
'babel-preset-expo',
'module:react-native-dotenv',
],
sourcemaps: true,
plugins: [
'@babel/transform-react-jsx-source',
],
};
};
- lastly, use
yarn
to install your packages (yarn install
) and to run your testsyarn test
.
score:1
expo automatically do setup of jest. i think you must do 'expo init newproject', then read .babelrc and package.json
below is result of expo init. it works well.
// package.json
{
"main": "node_modules/expo/appentry.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"eject": "expo eject",
"test": "node ./node_modules/jest/bin/jest.js --watchall"
},
"jest": {
"preset": "jest-expo"
},
"dependencies": {
"@expo/samples": "2.1.1",
"expo": "^32.0.0",
"react": "16.5.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-32.0.0.tar.gz",
"react-navigation": "^3.0.9"
},
"devdependencies": {
"babel-preset-expo": "^5.0.0",
"jest-expo": "^32.0.0"
},
"private": true
}
// babel.config.js
module.exports = function(api) {
api.cache(true);
return {
presets: ['babel-preset-expo'],
};
};
Source: stackoverflow.com
Related Query
- How to configure Jest to work with Expo SDK 32
- Can't get Jest expo app to work with react-navigation
- How to configure Info.plist file in ejected react-native app uses expo sdk
- How to use SVG in Expo SDK 40 React Native with TypeScript?
- How to unit test API calls with mocked fetch() in react-native with Jest
- How to configure source maps when using Jest within Visual Studio Code debugger
- How to use import with absolute paths with Expo and React Native?
- How to use Jest with React Native
- How to get URL Scheme myapp:// to work with Instagram API redirect uri
- How to run expo start with release-channels
- How to implement jest unit test with react-navigation
- How to mock react-native module (not 3rd party module) with jest
- How to test a button click in React with TypeScript, Jest and Enzyme
- How to test Alert in React Native with Jest
- React Native Expo App: How to get it to run Jest tests
- How to use enzyme for react-native with jest
- How to use firebase login with expo
- how to resize a photo with expo react native
- How to store sensitive data in React Native or expo code ? ( with Keychain and Keystore )
- Expo SDK 45 splash screen with react navigation
- How I can test in jest line with throw e?
- How to customize app.json to build a whitelabel app with Expo
- How do I use react-native-google-mobile-ads with Expo and Expo Go?
- How to debug React Native project created with Expo using TypeScript
- Share photo to Instagram from React-Native app built with Expo SDK
- How to unit test static navigationOptions with Jest and Enzyme while using React Navigation and TypeScript?
- How to mock Picker and Picker.Item with jest in React-Native?
- Incompatible react native SDK with expo SDK
- Test Jest React-Native Expo CRNA with Redux not ejected
- How to get FB Access Token with Expo
More Query from same tag
- React Native Grid View : Image messes up the view
- How to prevent multiple clicks on a butoon in react native?
- Await isn't waiting?
- AsyncStorage.getItem behaviour when key does not exist
- How can I bind an object to a SelectItem component?
- TypeError: Cannot read property 'upgradeElements' of undefined and issue 2 is TypeError: Cannot read property 'downgradeElements' of undefined
- Hide/Show button in React Native Toolbar
- React material ui textfield type number how to save decimal on change
- How To Update Redux State React Native
- React Native, accessing a single element from an array nested in state
- getConstants in React native
- How to remove padding or space from react native drawer items
- React Native: always gradlew clean before run react-native-run-android
- when using Actions.reset("key") in react-native-router-flux, what will affect the component
- How to programmatically navigate in React Router Native?
- Re-rendering the page when an element in the 2D array changes in react native expo
- Cannot get images to upload to wp/v2/media with React Native
- Could not find com.google.firebase:firebase-database: 15.0.0
- create an object using forEach
- Google Pay - ERROR: Request Failed - Unexpected developer error, please try again later
- react-native console.log inside componentWillUnmount
- React-native map: MapView with the Animated API is lagging too much in android
- how to update items object after on onTextChange in searchable dropdown in react native?
- TypeError: store.getState is not a function. (In 'store.getState()', 'store.getState' is undefined how can i resolve this problem?
- How to add sticky components in react native maps?
- zsh: command not found: emulator
- How to change the default font family of the entire react native app
- React Native - get url search params
- bundling failed Unexpected token react native
- how to vertically align to center navigation options on react native?