All Questions
27 questions
0
votes
0
answers
131
views
react-native jest and react-test-renderer always get error Element type is invalid and undefined
i try to write test for project in react-native for snapshot testing but when i run it always get error
Error: Element type is invalid: expected a string (for built-in components) or a class/function ...
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 ...
2
votes
2
answers
2k
views
TypeError: Cannot read properties of undefined (reading 'ReactCurrentOwner')
I have an npm monorepo which contains web apps (React 18), mobile apps (React-Native 0.71/React 18) and shared libraries. I am also using npm overrides to fix React versions, this has not changed. ...
2
votes
0
answers
266
views
How to pass in props to snapshot test React native typescript?
i am very new to testing and im trying to create a simple snapshot test for a presentational component that accepts props. Am I suppose to 'mock' some props? Also I am not using ts-jest as im not ...
2
votes
1
answer
306
views
jest test is not exiting after test passes with react-test-renderer
I have a toMatchSnapshot test on a simple component with React Native 0.68.2/jest 29.0. Here is the component SysError:
import React, {useState, useContext, Component} from 'react';
import {Platform, ...
0
votes
0
answers
1k
views
Couldn't register the navigator. Have you wrapped your app with 'NavigationContainer'?
it('renders correctly', async () => {
const tree = renderer
.create(
<TTopBar
tabBarScrollEnabled={true}
containerHeight={350}
...
1
vote
0
answers
324
views
React-Native test an event with multiple state changes
I have written the following method inside of a react-native w/Typescript functional component. This series of state changes is accomplishing two things: 1.) it is taking from one array (linked to a ....
3
votes
0
answers
2k
views
fireEvent.press not working (React Native Testing Library)
I am writing unit tests for my React Native project. My main screen is WelcomScreen.js and inside it is following custom button created using TouchableOpacity:
<TouchableOpacity
...
2
votes
0
answers
183
views
Component working fine being rendered but failed at snapshot testing
I've created a simple component that wrapped SVG as below:
import React from 'react';
import CheckOutline from '../../assets/svg/check-outline.svg';
import Check from '../../assets/svg/check.svg';
...
0
votes
1
answer
627
views
React Native testing components with depends on another components
I'm using Jest and react-test-renderer for test my components. When I test pure component with import only from react-native modules, everything is ok.
for example when I test below component:
import ...
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 ...
1
vote
1
answer
2k
views
TypeError: Cannot read property '__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED' of undefined React-test-renderer
I am using Jest with React Native and when I try to run a test I run in to the " TypeError: Cannot read property '__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED' of undefined" error. ...
3
votes
1
answer
3k
views
TypeError: Cannot read property 'params' of undefined Jest Testing - React Native
I have created a test file to test my following "BiddingScreen",
const BiddingScreen = ({ route, navigation }) => {
const { currentBid } = route.params;
return (
<SafeAreaView ...
2
votes
1
answer
173
views
Facing Warning: Failed prop type: Invalid prop `source` supplied to `Image`. when running jest testcase in react-native (expo)
Below is the code for error: Warning: Failed prop type: Invalid prop 'source' supplied to 'Image'.
const ParentComponent = () => {
return (
<Image source={require('app/assets/image.png')}/&...
1
vote
1
answer
1k
views
How to Debug Tests in React Native When Using Jest and Expo
I'm trying to setup some debugging for the tests in my app I'm building with React native on expo. I followed some instructions from online resources. Below are the settings from my package.json. When ...