All Questions
44 questions
0
votes
0
answers
98
views
Testing react native apps (Expo framework)
I have a simple question for people who use react-native and Expo.
I am using the following technologies
Styled-components
react-native-paper
Context API (for Authentication)
I am new to testing in ...
0
votes
3
answers
2k
views
TypeError: Cannot assign to read only property 'fetch' of object '[object global]'
I've encountered an error with my tests from a mysterious way.
Context :
I have a lot of testing files that work for everyone expect me.
In the only test that fail, the only issue is this line :
const ...
0
votes
0
answers
85
views
What am I doing wrong (testing Picker component in React Native app)?
I'm trying to test a react native (expo) app and have had success manipulating text inputs so far, however when I try to test the behavior of a custom select field (Picker), that triggers a state ...
1
vote
0
answers
145
views
TypeError: _reactNative.StyleSheet.create is not a function when testing a react native app with jest and RTL
I'm testing a react native app with Jest and React Testing Library, but every time i run the tests i get the following error:
TypeError: _reactNative.StyleSheet.create is not a function
enter image ...
2
votes
1
answer
1k
views
How to test that bottom sheet that use useRef open?
In react native, I have a bottom sheet that I'd like to test it opens properly when clicking on a button.
The bottomsheet is from the library Gorhom bottom sheet and it uses useRef with a method (...
1
vote
1
answer
2k
views
How to mock @react-navigation/native using jest and react testing library
I have header component, written in react native.
When onPress is triggered it should execute goBack function, but it just logs 'onPressCalled' and doesn't enter if statement. It looks like mock isn't ...
1
vote
1
answer
270
views
Test custom react native hook with useAsyncStorage inside
How can I test custom react native hook which has inside useAsyncStorage hook?
This is my hook:
export const useCustomHook = () => {
const storage = useAsyncStorage('item');
const [state, ...
1
vote
0
answers
582
views
Testing a component that calls an external function with Jest and React Native Testing Library
Suppose I have a component that calls a function, for example:
// AComponent.js
import { Text, View } from "react-native";
import { getAString } from "./utils/function";
const ...
1
vote
1
answer
1k
views
How to add Jest-React testing library to Expo
I'm trying to install Jest and React testing library to my expo project(sdk 47). While installing i'm getting dependency conflict. i'm new to testing can you please help me how to install
Found: ...
3
votes
1
answer
3k
views
How to resolve "render method has not been called" on failed jest test (react-native)
Writing a component test but test fails with an error of "render method has not been called."
MealCard.test.tsx
/**
* @jest-environment jsdom
*/
import { MenuProvider } from 'react-native-...
0
votes
0
answers
194
views
react - mockImplementation not working using jest
App.tsx
import { StackNavigationProp } from '@react-navigation/stack';
...
export const App = () => {
const rootNavigation = useNavigation<StackNavigationProp<ParamList>>();
const {...
0
votes
0
answers
390
views
Element of a screen still found by getByTestID after navigating on another screen
I hope I am not spamming too much... Actually, I deleted my previous questions to make this one and keep it small and up to the point.
I have a react native application built with expo with a Home ...
2
votes
1
answer
2k
views
Why isn't @testing-library/react-native fireEvent calling my onChange function?
I've looked at a number of different StackOverflow questions regarding issues with testing library fireEvent, and in every case, it seems the post was resolved by fixing poor handling of props or ...
2
votes
0
answers
1k
views
Testing a nested custom hook with react-testing-library
I'm trying to test a hook in isolation with @testing-library/render-hooks in a React Native project. The hook I have looks something like this:
const useStatus = () => {
const [ status, setStatus ...
0
votes
1
answer
431
views
react testing library, how to test setState inside useEffect
I have written a component that does two things :
show a banner: when netInfo.isConnected change and is false or when netInfo.isInternetReachable change and is still false after 3 seconds
hide a ...