moxios icon indicating copy to clipboard operation
moxios copied to clipboard

Stubs for certain request methods?

Open sezanzeb opened this issue 3 years ago • 6 comments

I want to add different stubs for GET and POST methods on the same URL.

sezanzeb avatar Apr 13 '21 12:04 sezanzeb

@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.

qs-labs avatar Apr 21 '21 12:04 qs-labs

By passing the method as first argument, the request will hang forever :-(

marcopeg avatar Jun 14 '21 10:06 marcopeg

This should work.

moxios.stubRequest('/say/hello', {
  method: 'POST',
  status: 200,
  responseText: 'hello',
})

nzwsch avatar Oct 17 '21 08:10 nzwsch

Looks like the /dist folder isn't updated with the latest source code.

Code in dist folder:

image

Code in index.js:

image

lior-chervinsky avatar May 29 '22 11:05 lior-chervinsky

:point_up: Could one of the developers please update the dist and publish a new package to npm? Thanks that would be wonderful!

filidorwiese avatar Feb 06 '23 12:02 filidorwiese

#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

willnguyen1312 avatar Apr 26 '23 14:04 willnguyen1312