axios / moxios

Mock axios requests for testing

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Wildcard Mock Not Working

AdrianHL opened this issue · comments

Hi,

I have some tests that require wildcards (see example below) but it doesn't look to be working as expected (the requests is not mocked).

moxios.stubRequest('/comments/.*/vote', { status: 200, response: { success: true } })

Any idea why this could be happening?

Thanks in advance

Hi mate!

I may be wrong, but I think wildcards should be RegExp, not strings, as in the example from README:

 // Alternatively URL can be a RegExp
 moxios.stubRequest(/say.*/, {/* ... */})

Try using /comments\/.*\/vote/ (without quotes).