You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
you should be able to use getReqMatching to get the request info and then use it as a second parameter for mockError (see docs) to replicate the behavior of mockResponseFor.
Adding mockErrorFor might be interesting for symmetry reasons, but it would only be a mere abstraction over existing methods as described above.
Ok, it works indeed, I put an example which can be useful I think:
Some context: I have many requests triggered in background (they can arrive in a random order) and I need to mock only a specific one.
// getting the extended info about the most recent requestconstlastReqInfo=MockAxios.lastReqGet();if(lastReqInfo&&lastReqInfo.url.includes('/myApiThatIWantToTarget')){mockAxios.mockError('You must fail ! \(ᵔᵕᵔ)/ ',lastReqInfo);}
Hello,
First of all, great job for this lib, I like it a lot. :)
Just a request if it's possible to do a function
axios.mockErrorFor
which will behave same asaxios.mockResponseFor
but sending an error ?Or is there a workaround to do it ?
Thanks !
The text was updated successfully, but these errors were encountered: