Configuration issue while setting up jest expo

Please provide the following:

  1. SDK Version: 39
  2. Platforms(Android/iOS/web/all): all

This is the package.json for the expo project:

{

  "main": "node_modules/expo/AppEntry.js",

  "scripts": {

    "start": "expo start",

    "android": "expo start --android",

    "ios": "expo start --ios",

    "web": "expo start --web",

    "eject": "expo eject",

    "test": "jest"

  },

  "jest": {

    "preset": "jest-expo",

    "transformIgnorePatterns": [

      "node_modules/(?!(jest-)?react-native|react-clone-referenced-element|@react-native-community|expo(nent)?|@expo(nent)?/.*|react-navigation|@react-navigation/.*|@unimodules/.*|unimodules|sentry-expo|native-base|@sentry/.*|muteWarnings)"

    ]

  },

  "dependencies": {

    "@react-native-community/masked-view": "0.1.10",

    "@react-native-community/netinfo": "5.9.2",

    "@react-navigation/drawer": "^5.8.2",

    "@react-navigation/native": "^5.5.1",

    "@react-navigation/stack": "^5.5.1",

    "axios": "^0.19.2",

    "babel-plugin-inline-dotenv": "^1.5.0",

    "expo": "^38.0.10",

    "expo-av": "~8.2.1",

    "expo-camera": "~8.3.1",

    "expo-document-picker": "^8.3.0",

    "expo-file-system": "^9.1.0",

    "expo-firebase-analytics": "~2.4.1",

    "expo-font": "~8.2.1",

    "expo-location": "~8.2.1",

    "expo-screen-orientation": "~1.1.1",

    "expo-status-bar": "^1.0.0",

    "moment": "^2.27.0",

    "moment-timezone": "^0.5.31",

    "native-base": "^2.13.12",

    "react": "16.11.0",

    "react-dom": "16.11.0",

    "react-moment": "^0.9.7",

    "react-native": "https://github.com/expo/react-native/archive/sdk-38.0.2.tar.gz",

    "react-native-extended-stylesheet": "^0.12.0",

    "react-native-gesture-handler": "~1.6.0",

    "react-native-google-maps-directions": "^2.1.1",

    "react-native-image-gallery": "^2.1.5",

    "react-native-image-gradient": "^2.2.5",

    "react-native-lightbox": "^0.8.1",

    "react-native-loading-spinner-overlay": "^1.1.0",

    "react-native-maps": "^0.27.1",

    "react-native-modals": "^0.19.9",

    "react-native-progress": "^4.1.2",

    "react-native-reanimated": "~1.9.0",

    "react-native-safe-area-context": "~3.0.7",

    "react-native-screens": "~2.9.0",

    "react-native-table-component": "^1.2.1",

    "react-native-web": "~0.11.7",

    "react-navigation": "^4.3.9",

    "react-navigation-image-gallery": "expo/react-native-image-gallery",

    "react-number-format": "^4.4.1",

    "react-redux": "^7.2.0",

    "redux": "^4.0.5",

    "rn-placeholder": "^3.0.1"

  },

  "devDependencies": {

    "@babel/core": "^7.8.6",

    "babel-preset-expo": "^8.2.3",

    "jest-expo": "^39.0.0",

    "react-test-renderer": "^16.14.0"

  },

  "private": true

}

When I run npm test it is giving the error:

 import { Component, Children } from 'react';
    ^^^^^^

    SyntaxError: Cannot use import statement outside a module

It seems that I need to provide the exact transformIgnorePatterns parameters, but I am missing few modules. I need help on that.

same issue with me

Configured the transformIgnorePatterns for Jest. The issue is now resolved.
Thanks.

1 Like

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