Jest - Test Gives An Error Typeerror: Cannot Read Property 'then' Of Undefined
When i the run test it gives me an error TypeError: Cannot read property 'then' of undefined, I've tried to look for some fix on the Docs but i didn't find one to fix this issue, a
Solution 1:
Be sure to return the promise from the anonymous function inside getContacts():
exportfunctiongetContacts() {
returnfunction(dispatch) {
dispatch({type: 'GET_CONTACTS_PENDING'})
axios.get('http://127.0.0.1:8000/api/contacts', { // THIS LINE
})
...
Change this:
axios.get('http://127.0.0.1:8000/api/contacts', {
to this:
return axios.get('http://127.0.0.1:8000/api/contacts', {
Right now it lacks a return statement and so returns undefined
.
Post a Comment for "Jest - Test Gives An Error Typeerror: Cannot Read Property 'then' Of Undefined"