All Questions
350 questions
0
votes
0
answers
35
views
React native with jest Cannot use import statement outside a module
I'm using react native 0.73.0, react 18.2.0, jest 29.6.3, and @testing-library/react-native 12.4.3. When I run command npx jest src/components/ActionButton/__tests__/ActionButton.test.js --...
0
votes
0
answers
50
views
Can't get Jest tests to run with reactotron-redux with the following error - SyntaxError: Cannot use import statement outside a module
I have a React Native project and was able to setup reactotron-react-native and my tests were still working fine, but as soon as I installed reactotron-redux and set it up as per documentation, all my ...
0
votes
1
answer
449
views
npm install is giving error - npm error ERESOLVE unable to resolve dependency tree
In my React Native with TypeScript project, I wanted to install dependencies.
To install Testing Libraries I've used this command:
npm install @testing-library/react-native @testing-library/jest-...
13
votes
1
answer
5k
views
Jest tests started failing with TypeError: A dynamic import callback was invoked without --experimental-vm-modules after recent React Native upgrade
I've been trying to resolve this test error for a while now with not success. Recently I upgraded React Native from 0.72.3 to 0.74.3 and got the Android application to build and run, however, I can't ...
0
votes
0
answers
125
views
Jest - react-native-color-matrix-image-filters/dist/CMIFColorMatrixImageFilterNativeComponent.js: Could not find component config for native component
I have a React Native Android project and I just upgraded the react-native version from 0.72.3 to 0.74.3. After a fair amount of library upgrading, TS and Lint fixes, etc I was able to get my ...
0
votes
1
answer
232
views
Jest SyntaxError: Unexpected identifier 'ErrorHandler'
I'm trying to write some unit tests in jest for a react native library I'm writing. However, I keep getting this pesky "unexpected identifier: 'Error Handler'" message. I've tried a lot of ...
0
votes
0
answers
43
views
Issue while writing Unit Test case with jest for testing a function depends on AuthContext state
I am getting an issue "TypeError: Cannot read properties of undefined (reading '_context')Jest" while writing Unit Test Case with jest in my react native project with java script.
I have ...
0
votes
0
answers
141
views
TypeError: Cannot read properties of undefined (reading 'colors') Jest Problem
My accordion-item.jsx
import React, {useCallback, useContext, useEffect, useState} from 'react';
import {TouchableOpacity} from 'react-native';
import PropTypes from 'prop-types';
import Animated, {
...
0
votes
0
answers
73
views
How to test js/jsx with jest in react native
I am trying to test a App.js file in react native with jest but the test is passing only when the file has ts extension. By default react native created ts/tsx files and I converted them to js/jsx as ...
1
vote
1
answer
275
views
test if a toast message was shown with Jest
I'm testing my react native application with Jest and I want to test when toast shows a message.
I'm using toast like this in one of my callbacks :
if (pinMismatch) {
Toast.show({
...
5
votes
1
answer
4k
views
Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'RNLocalize' could not be found, react native when importing redux state from jest testing
React native: Changing variable in redux state from test files in jest, after application build.
Since I cannot write the whole logic, components and props in the test file, I need to pass just one ...
0
votes
1
answer
233
views
Jest test failing due to async react native component
I have a basic test for the entry App.tsx:
import * as React from 'react';
import { NavigationContainer } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/...
0
votes
0
answers
37
views
How to write unit tests for React Native's useEffect hook inside which I'm using navigation.addListener('focus')?
I've created a React Native component define below, and it's utilised as a navigation screen through the react-navigation library.
const RecipeScreen = () => {
const [recipes, setRecipes] = ...
0
votes
1
answer
87
views
How do I test that an accessible embedded hyperlink is clickable/not clickable when the screen reader is on/off?
I have a function that detects whether the screen reader is enabled or not within a react native application. If it is enabled then an embedded hyperlink within a Text component will be "...
1
vote
2
answers
133
views
How to test a react native component whose UI changes based on async call in useEffect hook
I have a react native component OrdersScreen which I am not able to test because the component gets updated when setState : setRenderLoader(false) is called in React.useEffect() hook.
const ...