expo: Expo 31 Jest transform error repro in tabs project template
Expo CLI 2.2.5
expo init expo-31-project, choose tabsrm -rf node_modules && npm inpx jest- Jest error:
Jest encountered an unexpected token
expo-31-project/node_modules/expo/build/environment/logging.js:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import { Constants } from 'expo-constants';
SyntaxError: Unexpected token {
at ScriptTransformer._transformAndBuildScript (node_modules/jest-runtime/build/script_transformer.js:403:17)
at Object.<anonymous> (node_modules/expo/build/Expo.js:284:1)
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 1
- Comments: 23 (5 by maintainers)
Commits related to this issue
- Uninstall jest and babel-jest jest and babel-jest are unnecessary when using jest-expo https://github.com/expo/expo/issues/2595#issuecomment-440966998 — committed to joeyschroeder/expo-react-native-redux-starter by joeyschroeder 6 years ago
- Amplify and Jest Sample Add a new emptyish Expo app to demonstrate Amplify and Jest not playing well together with (mostly) out of the box settings. Includes the workaround for issue [expo/expo#2595... — committed to josephbridgwaterrowe/amplify-and-jest-sample by josephbridgwaterrowe 5 years ago
- Amplify and Jest Sample Add a new emptyish Expo app to demonstrate Amplify and Jest not playing well together with (mostly) out of the box settings. Includes the workaround for issue https://github.... — committed to josephbridgwaterrowe/amplify-and-jest-sample by josephbridgwaterrowe 5 years ago
- Amplify and Jest Sample Add a new emptyish Expo app to demonstrate Amplify and Jest not playing well together with (mostly) out of the box settings. Includes the workaround for issue https://github.... — committed to josephbridgwaterrowe/amplify-and-jest-sample by josephbridgwaterrowe 5 years ago
- Amplify and Jest Sample Add a new emptyish Expo app to demonstrate Amplify and Jest not playing well together with (mostly) out of the box settings. Includes the workaround for issue https://github.... — committed to josephbridgwaterrowe/amplify-and-jest-sample by josephbridgwaterrowe 5 years ago
Thanks @artyorsh for sharing, unfortunately your repo might be a bit confusing for someone that doesn’t want all the typescript stuff, as that is a significant part of your jest configuration.
The only thing that actually seems to be needed is:
installed jest-expo (not jest!) jest.config.js file:
leave the babel.config.js the way it was
@Overtorment @metz0r Please try and let me know if that helps.
My package.json:
Still having this issue even after creating a brand new project with tabs using expo.
npm version: 6.2.0 node version: 10.9.0
See image
@bruno-edo answered my question here. The basic gist is use
yarninstead ofnpm. Seems like the Expo dev’s didn’t test their code withnpmandnpmmesses things up.@c316 Thank you for bringing that up. I updated the original comment with my approach to using the workaround: https://github.com/expo/expo/issues/2595#issuecomment-443193112
@freeatnet it isn’t clear how to use that workaround. Can you post some more information on how to implement that workaround?
Hey! It looks like
npminstalls different dependencies versions thanyarn, try installing deps withyarn. 🙂