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
I'm using fetch-mock in Jest (using fetch-mock-jest). I'm using fetch-mock v9.11.0.
The code I'm using looks like this:
constendpointUrl='https://api.profiler.firefox.com/profile/0123456789';fetch.config.overwriteRoutes=true;fetch.catch(404)// Catchall.mock(endpointUrl,405)// method not allowed for all methods but delete.delete(endpointUrl,406)// Not acceptable for other Accept values.delete({url: endpointUrl,headers: {'Content-Type': 'application/json',Accept: 'application/vnd.firefox-profiler+json;version=1.0',},},401// Unauthorized when no Bearer or no valid Bearer).delete({url: endpointUrl,headers: {'Content-Type': 'application/json',Accept: 'application/vnd.firefox-profiler+json;version=1.0',Authorization: `Bearer NOT_A_TOKEN`,},},200);
Hi, thanks for this easy to use library.
I'm using fetch-mock in Jest (using fetch-mock-jest). I'm using fetch-mock v9.11.0.
The code I'm using looks like this:
Then the call looks like this:
I would have expected that the last matcher doesn't match, but then the previous one would match. But here the
catch
matcher is used instead.I believe this is because the last matcher overwrites previous ones.
When I use
fetch.config.overwriteRoutes = false
instead, then the matcher returning405
is used.Finally, if I add
name
values for all matchers, without settingfetch.config.overwriteRoutes
, then the matcher returning405
is also used.Any idea how to make this use case work declaratively?
In the mean time I'll use a function to select the right response.
Thanks!
The text was updated successfully, but these errors were encountered: