How to test useEffect with Auth api and state inside

useEffect(()=>{ Auth.currentAuthenticatedUser().then((user) => { setUser(user) setIsLoading(false) if (user.challengeName === 'NEW_PASSWORD_REQUIRED') { navigate('/ForceChangePassword') } else{ navigate('/App') } }).catch(error => { console.log('isCurrentAuthenticatedUser- ',error) setUser(null) setIsLoading(false) }) }); Answers: Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. … Read more