You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 30, 2020. It is now read-only.
The example on this repository's readme file isn't working, but the one on the docs is working fine, it would be helpful to have the same example in order for the new comers not get frustrated that the example isn't working.
importReactfrom'react';import{Button,Text,TextInput,View}from'react-native';import{fireEvent,render,wait}from'@testing-library/react-native';functionExample(){const[name,setUser]=React.useState('');const[show,setShow]=React.useState(false);return(<View><TextInputvalue={name}onChangeText={setUser}testID="input"/><Buttontitle="Print Username"onPress={()=>{// let's pretend this is making a server request, so it's async// (you'd want to mock this imaginary request in your unit tests)...setTimeout(()=>{setShow(!show);},Math.floor(Math.random()*200));}}/>{show&&<TexttestID="printed-username">{name}</Text>}</View>);}test('examples of some things',async()=>{const{ getByTestId, getByText, queryByTestId, baseElement }=render(<Example/>);constfamousWomanInHistory='Ada Lovelace';constinput=getByTestId('input');fireEvent.changeText(input,famousWomanInHistory);constbutton=getByText('Print Username');fireEvent.press(button);awaitwait(()=>expect(queryByTestId('printed-username')).toBeTruthy());expect(getByTestId('printed-username').props.children).toBe(famousWomanInHistory);expect(baseElement).toMatchSnapshot();});
The text was updated successfully, but these errors were encountered:
Details
The example on this repository's readme file isn't working, but the one on the docs is working fine, it would be helpful to have the same example in order for the new comers not get frustrated that the example isn't working.
The text was updated successfully, but these errors were encountered: