I have a students component
function Student(props)
{
const [studentData,setStudentData]=useState([]);
function getStudentData()
{
axios
.get("myAPI/getStudentData")
.then {}
.catch(error=>
{
console.log(error);
}
}
useEffect(()=>{
getStudentData();
},[]);
}
my React test is as follows:
it('failure', async()=>
{
const api = Promise.reject('API has failed');
axios.get.mockImplementation(()=> api);
render(<Student />);
///Here how to test if I am getting 'API has failed' in console ?
expect('API has failed').toBeInTheDocument()???????
})
My question is: When I put debug(), I can see 'API has failed' is printed in console output But how to test it using something like 'expect'?