Questions tagged [react-native-testing-library]

The react-native-testing-library is a lightweight solution for testing your React Native components. It provides light utility functions on top of react-test-renderer letting you always be up to date with latest React features and write any component tests you like.

The react-native-testing-library is a lightweight solution for testing your React Native components. It provides light utility functions on top of react-test-renderer letting you always be up to date with latest React features and write any component tests you like.

This library is a replacement for Enzyme. It is tested to work with Jest, but it should work with other test runners as well.

https://github.com/callstack/react-native-testing-library

177 questions
1
vote
1 answer

Testing Library React Native

How to check disabled button in formik form with testing library react native? This is my form js. In this form, I have text input will testId input_email, if the email is not valid, the button submit should be disabled. /* eslint-disable indent…
1
vote
2 answers

React Native testing android and ios component

I have a code that goes like this: function AppContainerAndroid() { return ; } function AppContainerIOS() { return ( ); } function…
happy go lucky
  • 361
  • 3
  • 13
1
vote
1 answer

test prop that's receiving number with testing-library/react-native

i tried to read the documentation of at testing-library/react-native and i searched on stackoverflow but i didn't found a good result. I have this component import React from 'react'; import { CardContainer, Title, Icon, Item, ClickableItem,…
1
vote
0 answers

Error taking snapshot after using material-top-tabs because of react-native-reanimated mock

Current Behavior After using @react-navigation/material-top-tabs my snapshot fails given the following error TypeError: Cannot read property 'name' of undefined at Object.onIndexChange…
1
vote
1 answer

How to get React Test Renderer instance in React Native Testing Library

I have a component with a lifecycle method added by the navigation library - React Native Navigation (https://wix.github.io/react-native-navigation/#/docs/Usage?id=screen-lifecycle). I must call this lifecycle method (componentDidAppear) in tests…
1
vote
1 answer

Testing StyleSheet using react-native-testing-library

In our react-native application, we are developing custom style component for our component. The style component contains StyleSheet example: export default StyleSheet.create({ container: { flexGrow: 1, justifyContent: "center", …
1
vote
2 answers

fireEvent on SegmentedControlIOS

I am using react-native-testing-library - https://callstack.github.io/react-native-testing-library/docs/getting-started I have a - https://facebook.github.io/react-native/docs/segmentedcontrolios I want to pres the first…
Noitidart
  • 35,443
  • 37
  • 154
  • 323
0
votes
1 answer

React Native Unit Testing - Can't access .root on unmounted test renderer

Hello I'm testing my app with react-native-testing-library. When i run test returning test fail How can i solve this? Error is: Can't access .root on unmounted test renderer There seems to be an issue with your configuration that prevents React…
0
votes
0 answers

Not able to get coverage for the code written inside viewAbilityConfigCallbackPairs in jest

I have basically written a code of flatlist and used viewabilityConfigCallbackPairs props. Divided UI code and business logic in separate file. Now the issue is I am trying to write testcase using jest for the same but it seems…
0
votes
2 answers

Cannot Find TestID for react-native Unit test cases, following is the description for the same

Test Case: it("Test Email text by test id" , () => { const testIDName='email-title'; const {getByTestId} = render( ); const…
0
votes
0 answers

React Native Jest Error: ReferenceError: Headers is not defined

I'm using React Native with redux-toolkit When I'm trying to run jest I get this error: "jest": "^29.2.1", "@reduxjs/toolkit": "^1.8.6",
0
votes
1 answer

@testing-library/react-native mock axios post timesHaveBeenCalled(1) is 0

I need help figuring out how to mock an axios post request. The docs have failed me. I've tried just about every combination I could find on stack overflow. All end up with either typescript errors or the undesired results shown below... The…
0
votes
1 answer

JEST test passes, act not correctly used?

I do some unit testing, here is my code: import React from 'react'; import { render, fireEvent, act, waitFor } from '@testing-library/react-native'; import { LoginScreen } from '../login.screen'; describe('Login screen', () => { //Testing Login…
0
votes
1 answer

Having trouble to test my component with ref using react-native-testing-library and react-native-reanimated

I am trying to test my toast component (uses react-native-reanimated under the hood) using react-native-testing-library but when I try to show my toast the ref is null. I cannot understand why: This is my test scenario: import React from…
0
votes
1 answer

How to write unit test for React Native Switch's value prop

I am using React Native Switch. I want to write a unit test (using jest and testing-library/react-native) for its value prop. But there is no value in its props My use case is there will be a default value for the Switch when the page load. But I…
manh.vu
  • 335
  • 1
  • 4
  • 14