moxios
moxios copied to clipboard
Stubs for certain request methods?
I want to add different stubs for GET and POST methods on the same URL.
@sezanzeb I myself haven't gotten stubs to work but checkout the declaration for stubRequest
, it supports an optional first parameter allowing you to specify the type of axios request.
By passing the method as first argument, the request will hang forever :-(
This should work.
moxios.stubRequest('/say/hello', {
method: 'POST',
status: 200,
responseText: 'hello',
})
Looks like the /dist
folder isn't updated with the latest source code.
Code in dist folder:
Code in index.js:
:point_up: Could one of the developers please update the dist and publish a new package to npm? Thanks that would be wonderful!
#106 should fix this. I'm not so sure who is in charge as of now since the package is untouched for a while already 😅
As a work around, you could absolutely clone the repo, build it and push to Github or whatever repository you can have access to and install via the trick below. https://stackoverflow.com/questions/39732397/install-specific-branch-from-github-using-npm
In my case, I created one at https://github.com/willnguyen1312/moxios/tree/main and install like so:
pnpm add willnguyen1312/moxios#main