All Questions
143
questions
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
...
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 ...
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> ...
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:
...
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 ...
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: ...
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]....
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-...
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.
...
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 ...
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 ...
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 ...
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.
{...
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 ...
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",
&...
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/...
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 ...
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, ...
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
....
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 ...
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/...
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 :
...
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 ...
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....
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 ...
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,
...
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 - ...
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 (...
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/...
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 ...
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 (
<...
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 ...
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 ...
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 ...
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\[...
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() {
...
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 ...
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 ...
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()` ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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:
...
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 ...
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 '...
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 ...
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
× ...