-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError: Cannot read properties of undefined (reading 'then') in component axios call #85
Comments
Hi, thanks for raising this issue. Can you do |
Sure thing! looks like it is to me
Let me know if you'd like the full output. I will mess around in the debugger and add any interesting data I can find. |
This is what I see in the debug console.... odd.... (breakpoint is inside the component function that uses axios)
|
Can you try going to v4.5.0? |
Same error I am afraid, thanks so much for helping me look in to this |
What does your import look like? |
|
That's strange. I'll try to look into this on the weekend |
Much appreciated! I couldnt get axios-mock-adapter to work either, nor my own mocks, so it may well not be an issue with this particular library. Perhaps having an axios call nested in a component method is not something commonly tested this way? Its also possible my jest env is mucking something up, I just don't know what. |
Aha,
Appears to change the behavior to work... which is odd because false is the default? https://jestjs.io/docs/configuration#resetmocks-boolean We are running older versions of several libraries, so I suspect the issue is there. thanks for the help! sorry that this was not an issue with the library, I might turn it in to a stack overflow thread. |
Thanks for finding this out! This is very interesting, as the behavior used to be different when |
@KeynesYouDigIt's snippet worked for me, thanks, saved me an hour of debugging. Not sure why though. |
Version: "jest-mock-axios": "^4.6.1"
I have a react component that binds a function to an
onClick
eventand it makes an http call
I set up
mockAxios
as suggested by the read me. For some reason, when I.simulate('click')
on the button node, I get this crap, like post didnt return a promise?Does anyone know if axios being nested in a function means the mock wont work? or is there another thread to tug at?
The text was updated successfully, but these errors were encountered: