how to test if i give isSuccess true at 1 second ? (when loading screen is done)
const [state, setState]= useState({
isLoading: true,
isSuccess: false
})
useEffect(() => {
setInterval(() => {
setState({
isSuccess:true
});
}, 1000)
});
if (!state.isSuccess) {
return <p data-testid='fetching-data' className='text-center'>"loading..."</p>
}
I tried like this but it doesn't work :
test('isSuccess true', async()=>{
render(<App/>)
const ele = screen.getByText(/learn react/i)
await waitFor(() => expect(ele).toBeInTheDocument())
})