Problems running Jest


#1

I am running into a problem off a fresh project created via the Expo CLI, where Jest throws the following error after running “npm run test”:

Details:

    /Projects/react-native-project/node_modules/react-native/jest/setup.js:265
    const allRNMocks = { ...mockNativeModules, ...mockNativeModuleJS };
                         ^^^

    SyntaxError: Unexpected token ...

      at ScriptTransformer._transformAndBuildScript (node_modules/jest-runtime/build/script_transformer.js:403:17)

Here is the contents of 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
}

I am also encountering this same issue on a project with Expo 31.0.0.

I have deleted node_modules and done an npm install a few times, but it’s still not working. Please let me know if there is already a thread about this problem that I can reference or if the solution is an easy fix. Thank you!


#2

Bump. Anyone have any ideas? It seems as though all new projects would be running into this issue?


closed #3

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.