Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
20 votes
1 answer
48k views

Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax

I'm using ignite to create an expo react native app. I'm using this guide https://ignitecookbook.com/docs/recipes/GeneratorComponentTests to create component test files Here is the first test file ...
monty_lennie's user avatar
  • 3,161
14 votes
4 answers
12k views

No native ExponentConstants module found, are you sure the expo-constants's module is linked properly?

I'm getting these warnings when I run my expo / jest project and I'm not sure why, seemed to not come up when googled. console.warn The "EXNativeModulesProxy" native module is not ...
ThomasReggi's user avatar
  • 58.1k
14 votes
1 answer
670 views

Error : Cannot read property fetch. Using jest-expo with react native

TypeError: Cannot read property 'fetch' of undefined at node_modules/whatwg-fetch/fetch.js:4:8 at Object.<anonymous> (node_modules/whatwg-fetch/fetch.js:466:3) at Object.<anonymous> ...
Vyas Reddy's user avatar
  • 1,256
11 votes
1 answer
4k views

How to avoid Typescript transpiling Jest __mocks__

I'm getting a warning from Jest for each manual mock I have, because it finds both the .ts and .js version of it and asks me to delete one, i.e.: jest-haste-map: duplicate manual mock found: ...
jhm's user avatar
  • 4,469
8 votes
1 answer
5k views

Is it actually possible to make Detox/Jest tests pass with a React Native app running with Expo?

I'm attempting to create an automated UI test suite for my React Native app with Expo. I have looked everywhere for good tutorials but when I get to the actual test writing portion, my tests never ...
Chase Small's user avatar
8 votes
4 answers
6k views

The following files share their name; please adjust your hasteImpl: * <rootDir>\package.json * <rootDir>\sanity\package.json

This is my first time using sanity and I have encounter with this problem, When running expo start , I will be very thankful if you can help me with this jest-haste-map: Haste module naming collision: ...
Abdellah Slimani's user avatar
8 votes
1 answer
6k views

How to ignore typescript errors in jest

how to ignore some typescript errors when running the tests with jest ? I have tried to use // @ts-ignore comment, but still not working for jest. I am using jest-expo which internally uses [email protected]....
Ehsan Sarshar's user avatar
7 votes
0 answers
854 views

Testing react components in jest-expo always fails

I have followed the following tutorial for installing Jest with expo. https://docs.expo.io/versions/latest/guides/testing-with-jest/ After following this tutorial I encountered these errors: react-...
Steven Leunk's user avatar
6 votes
4 answers
2k views

jest-haste-map: Haste module naming collision (AWS, RN)

I have a React-native project with AWS Amplify. In the root directory, there is an amplify folder. Inside this amplify folder, there is a backend folder, and a #current-cloud-backend folder. ...
Cevin Thomas's user avatar
6 votes
1 answer
3k views

React Native Expo App: How to get it to run Jest tests

So Jest seems to be broken out of the box right now, when creating a React Native App with Expo. Steps to reproduce: `expo init' Choose tabs. cd into your app. Run npm test 👉🏻 Fails I googled and ...
J. Hesters's user avatar
  • 14.2k
6 votes
1 answer
2k views

Test runner (jest) failing to import expo modules

I'm writing some component tests for a React Native app. I'm using expo's BarCodeScanner for one of my components. In my jest test, I have a line that says import { BarCodeScanner } from 'expo';. This ...
thisissami's user avatar
  • 16.1k
5 votes
8 answers
25k views

TypeError: _API.default is not a constructor with Jest tests

I have an API class that I am trying to use in a React app. // API file class API { ... } export default API; // Other file import API from "utils/API"; const api = new API(); And I am ...
Steven Matthews's user avatar
5 votes
2 answers
2k views

IDE does not recognize Jest and its functions

I have a basic react-native/expo template app. I have added jest-expo and react-test-renderer in the dev dependencies, and also have updated package.json like documented in the expo docs for testing. {...
Msw Tm's user avatar
  • 500
5 votes
1 answer
2k views

react-native, jest, ts-jest: ReferenceError: React is not defined

I have been struggling for a couple of days now to get tests running for simple react-native with expo + typescript + jest + ts-jest. I have already asked a related question here Here is the setup of ...
TheSoul's user avatar
  • 5,196
5 votes
1 answer
10k views

Jest: React-native: TypeError: Cannot read properties of undefined (reading 'testEnvironmentOptions')

I am trying to set up the test environment on a newly created react native application based on the expo. The package.json file for it is { "name": "react-native-application", &...
Sumit Surana's user avatar
  • 1,554
5 votes
1 answer
729 views

Mocking libraries in Jest

I have some tests that keep failing.. Test suite failed to run TypeError: Cannot read properties of undefined (reading 'ignoreLogs') 33 | // https://reactnavigation.org/docs/...
cohs's user avatar
  • 85
5 votes
1 answer
2k views

TypeError: Cannot read property 'viewManagersNames' of undefined - Integrating Jest and Enzyme with React Native TypeScript Package

I'm trying to integrate Jest unit testing with Enzyme on my React-Native Typescript package, but after reading docs and tutorials, I can't seem to make it work. The problem only happens when using ...
Alexandre Zajac's user avatar
5 votes
1 answer
2k views

Testing Expo Constant with Jest, Jest encountered an unexpected token

I'm switching a SDK from Expo managed workflow to Expo bare workflow to reduce some of the unnecessary libraries included in Expo. I'm currently using some of the libraries such as Secure-store, ...
12332kc's user avatar
  • 91
4 votes
1 answer
6k views

Using Jest to mock named imports

I have a 'notifications.js' module that looks a bit like this: import { Notifications, Permissions } from 'expo' export function setLocalNotification(storage = AsyncStorage) { return storage ....
BarthesSimpson's user avatar
4 votes
2 answers
4k views

NativeBase Content not rendered in Jest with react-native-testing-library

I have some react-native/expo with native-base code that runs normally on the phone or emulator. I tried creating a test for it using jest and react-native-testing-library. When doing so, whatever is ...
Pedro Borges's user avatar
  • 1,260
4 votes
3 answers
12k views

Testing expo with enzyme: jest-environment-enzyme does not export getVmContext

I'd like to use enzyme to test my React-Native components in Expo managed project. I follow the docs for jest-expo-enzyme, but now I get: Test environment found at "/Users/raarts/myproject/...
raarts's user avatar
  • 2,891
4 votes
1 answer
4k views

SyntaxError: Cannot use import statement outside a module: when running Jest-expo tests

The configuration for the project. Currently using jest-expo for testing in this project. The version of jest-expo in the project is 39.0.0. Version of Jest installed globally is 26.6.3 package.json : ...
Teja Goud Kandula's user avatar
4 votes
1 answer
996 views

React Native - JEST: react-native/jest/hasteImpl.js in the haste.hasteImplModulePath option was not found

I am implementing jest on a react native application based on expo.io After following the implementation notes I have been able to successfully pass the jest tests on my system The issue is with ...
Hammad Khalid's user avatar
4 votes
1 answer
606 views

Can't Test React Native Components in a Monorepo

Hi I'm trying to test React-Native components in a monorepo. I have an apps/mobile folder with a react-native app in it. I have a packages/ui with a simple button component that only uses react-native....
Mike Fisher's user avatar
4 votes
1 answer
2k views

How to unit test function in ImagePicker Expo using React native testing library?

I have this code below in react-native using expo, which is a button, click on the button will call ImagePicker.requestMediaLibraryPermissionsAsync(), if the permission is granted, then call to ...
ken's user avatar
  • 2,612
4 votes
1 answer
3k views

Issue Testing the DateTimePickerModal with Jest & React Native Testing Library

I am trying to write unit tests for the React Native Modal DateTime Picker using Jest and the React Native Testing Library. I've passed in 3 (what I believe are) standard RN props: accessible: true, ...
Metal Gabe's user avatar
4 votes
0 answers
1k views

jest test freezes with typescript

Repo with reproduction: https://github.com/nmatushevskiy/jest-with-typescript Hello everyone, i've had a strange issue. I'm using jest, typescript, react-native, expo, babel, and components library - ...
nmatushevskiy's user avatar
4 votes
0 answers
576 views

react-native jest: cannot read property 'default' of undefined

I have looked at a number of solutions for this problem online but none has worked for me (e.g this). So I am trying to run my tests in a react-native + expo + typescript project. Here is my test (...
TheSoul's user avatar
  • 5,196
3 votes
1 answer
1k views

After upgrading to Expo48 Meeting this error: TypeError: Cannot read properties of undefined (reading 'exists')

After upgrading my project from Expo45 to Expo48, I encounter this error when running the test: TypeError: Cannot read properties of undefined (reading 'exists') at exists (node_modules/expo-asset/src/...
Zachary Zhao's user avatar
3 votes
1 answer
2k views

Typescript error for React test Renderer JSON not having Children

I have created an expo app with the basic typescript template as documented. Installed all the requirements needed for testing and its types. I can run the test, and it does pass the test. However, I ...
Msw Tm's user avatar
  • 500
3 votes
1 answer
528 views

Jest-Expo crashes on example (React.createElement: type is invalid -- expected a string)

I'm very confused on why the example test isn't running. I'm using Expo Web here with typescript. My frontend runs fine using expo start --web. // App.tsx const App = () => { return ( <...
Kipnoedels's user avatar
  • 1,315
3 votes
1 answer
864 views

Test Jest React-Native Expo CRNA with Redux not ejected

How to get all tests working for Components, Redux Actions and Reducers for a Create React Native App (CRNA) using Expo (default) while not ejected? Also uses Axios, Redux-Thunk async actions and ...
Thomas Hagström's user avatar
3 votes
1 answer
2k views

React Native Expo - Jest - React Native Firebase - Invariant Violation: Native module cannot be null

I try to run tests with jest but it breaks with an error: Invariant Violation: Native module cannot be null. at invariant (node_modules/invariant/invariant.js:40:15) at ...
Shaq's user avatar
  • 377
3 votes
1 answer
979 views

Jest: Test suite failed to run (The Expo SDK requires Expo to run)

I’m having a really hard time getting Jest up and running with my RN expo project (so I can play around and learn it). FAIL screens/HomeScreen.test.js ● Test suite failed to run The Expo SDK ...
Norfeldt's user avatar
  • 9,220
3 votes
1 answer
362 views

Jest-expo test doesn't run

If I follow this readme: https://github.com/expo/expo/tree/master/packages/jest-expo My output when running npm run test is this: > [email protected] test C:\Users\[username]\Documents\Projects\[...
marchello's user avatar
  • 2,106
3 votes
1 answer
2k views

How to mock StatusBarManager.getHeight in Jest test?

I'm using expo 34 and react-native-ui-lib from wix and have a problem to setup jest tests for my components. The problem looks to appear in link of the wix library function setStatusBarHeight() { ...
victor zadorozhnyy's user avatar
3 votes
1 answer
906 views

Jest tests fail after upgrading react-native from 0.70.5 to 0.71.3

After upgrading from expo SDK 47 to 48 and consequently upgrading react-native etc. my jest tests are failing. I found that its specifically after running npx expo install [email protected] that the ...
koch10's user avatar
  • 31
3 votes
1 answer
2k views

Expo secure-store unavailable in jest tests

This question is specifically about expo-secure-store and jest. Currently, I am using expo-secure-store to store my JWT when logging in. It works fine when running on emulator however, it doesn't work ...
Tony's user avatar
  • 466
3 votes
0 answers
895 views

How to mock react-navigation properly with jest?

I get the following during npm test: console.warn node_modules/react-navigation/src/react-navigation.js:23 `createNavigationContainer()` has been deprecated, please use `createAppContainer()` ...
Gregory01's user avatar
3 votes
1 answer
1k views

Can't get Jest expo app to work with react-navigation

I am trying to snapshot test with Jest, Expo, React Navigation and my whole app uses hooks only. I'd like to eventually make these into e2e tests where Jest clicks through and snapshot tests ...
so001's user avatar
  • 434
2 votes
1 answer
5k views

react-native-vector-icons/MaterialIcons jest-expo snapshot test error with typescript

I learning jest, writing my first snapshot tests for components using react-native & expo. I can run the test without the Icon component from 'react-native-vector-icons/MaterialIcons' inside my ...
Sam F.H.'s user avatar
  • 141
2 votes
1 answer
4k views

Error setting up Detox on React-Native/Expo mobile app: "ReferenceError: element is not defined"

I am trying to set up end-to-end testing with Detox on a React-Native/Expo mobile app. The app and Jest are currently working fine, but Detox tests give ReferenceError's. I have followed the ...
Paul B's user avatar
  • 493
2 votes
1 answer
1k views

Jest tests in an Expo app with react-native-paper

I have an Expo app that I'm setting up. I've added Jest tests and they work fine. I want to use react-native-paper for styling but when I add that and modify the one page I have so far to use it the ...
John East's user avatar
  • 126
2 votes
1 answer
1k views

No handler function found for event: "changeText"

I am trying out the React Native Testing Library with Expo / Jest for the first time. Following the tutorials, I can get a simple button to work test("Simple Button", () => { const ...
mdem's user avatar
  • 23
2 votes
2 answers
2k views

How to configure Jest to work with Expo SDK 32

I have an Expo app and was using SDK 28. My team decided we should update to the latest version, that meant updating React Native (Since the latest SDK uses RN 0.57) and Babel. When we updated our ...
Bruno Eduardo's user avatar
2 votes
1 answer
831 views

Expo Jest can't find images like '[email protected]'

As you know, Expo uses adaptive images size by analyzing the suffix of the file like the following: [email protected] [email protected] [email protected] I can declare the images omitting the end of the file like that: ...
1156752's user avatar
  • 3,903
2 votes
3 answers
2k views

Jest Mocking Permissions of Expo TypeError: Cannot read property 'askAsync' of undefined

I'm mocking expo and the Permissions module, but when calling Permissions.AskAsync Permissions is undefined. Problem looks like this question. Using Jest to mock named imports Used the provided ...
Wiezalditzijn's user avatar
2 votes
1 answer
883 views

Jest: mock out Expo releaseChannels

Been trying trying out a lot of things but without luck. I'm trying to test out my configuration for different release channels in expo. My latest attempt looks like this: import * as Updates from '...
Norfeldt's user avatar
  • 9,220
2 votes
2 answers
961 views

React native jest test with expo-constants and extra property

I have a react native expo app. I am currently writing tests for said app and there is a problem. I am using app.config.ts to export some variables with the extra property. In my file i am reading the ...
Asaraspo's user avatar
2 votes
0 answers
301 views

RequestContentLengthMismatchError error when using jest for testing react native fetch apis

I have a expo app and inside it some simple CRUD operations. App is works fine but when I want to write some test scenarios using jest, I get this error : FAIL apis/index.test.tsx Fetching Tests × ...
Obtice's user avatar
  • 1,225