Expo and Jest not working well together


#1

I’ve been using Expo for 3 weeks now, I’ve come to the point where I want to test things, for this I’ve seen Jest being the most used plug-in to test with react-native apps. However when installing Jest, my entire app will not run anymore and will give me no errors or whatsoever other than that the phone can’t contact the app. If I remove the node_modules and remove the Jest dependency, run npm install again, my app will work again. What am I doing wrong?

My package.json

{
“name”: “AwesomeApp”,
“jest”: {
“preset”: “jest-expo”
},
“version”: “0.0.0”,
“description”: “Hello Expo!”,
“author”: null,
“private”: true,
“scripts”: {
“test”: “jest”
},
“main”: “node_modules/expo/AppEntry.js”,
“dependencies”: {
“babel-preset-react-native-stage-0”: “^1.0.1”,
“dateformat”: “^2.0.0”,
“es6-promise”: “^4.1.1”,
“eslint”: “^4.7.0”,
“expo”: “^20.0.0”,
“flow”: “^0.2.3”,
“mobx”: “^3.2.2”,
“mobx-react”: “^4.2.2”,
“moment”: “^2.18.1”,
“native-base”: “^2.3.2”,
“react”: “15.6.1”,
“react-native”: “https://github.com/expo/react-native/archive/sdk-20.0.0.tar.gz”,
“react-native-datepicker”: “^1.6.0”,
“react-native-modal”: “^4.0.0”,
“react-native-vector-icons”: “^4.4.0”,
“react-navigation”: “^1.0.0-beta.11”
},
“devDependencies”: {
“babel-eslint”: “^8.0.0”,
“babel-plugin-transform-decorators-legacy”: “^1.3.4”,
“eslint”: “^4.7.0”,
“eslint-plugin-react”: “^7.3.0”,
“jest-expo”: “^21.0.2”
}
}


#2

That’s very strange. We test jest-expo with Expo. One thing I noticed is your version of jest-expo is 21 but you are using expo version 20. Can you try using jest-expo version 20?


#3

I’ve put this in my package.json : “jest-expo”:"^20.0.0". For some reason it gives me empty logs when I try to start the app, as its stuck on the load screen of the app, should I perform a npm cache clean?

Edit : I’ve performed a cache clean with this as well, I run my app with the XDE on port exp and LAN + development mode, I get to see these two logs and its stuck on the loading screen :
9:58:40 AM Building JavaScript bundle
9:58:51 AM


#4

I have solved it by updating my Expo version and downgrading my jest-expo dependency as that one was giving issues on the latest version. Thank you


#5

true, downgraded the version to
"jest": “^22.0.5”,
“jest-expo”: “22.0.0”,

it works now