[fetch-mock] Add Mock Configuration Options

This commit is contained in:
Quentin Bouygues 2018-03-06 14:37:03 +01:00
parent 716c8476f3
commit 0dde12db1f
2 changed files with 8 additions and 0 deletions

View File

@ -61,6 +61,7 @@ fetchMock.patch("http://test.com", 200);
fetchMock.patchOnce("http://test.com", 200);
fetchMock.get("http://test.com", 200, {method: "GET"});
fetchMock.get("http://test.com", 200, {method: "GET", overwriteRoutes: true});
fetchMock.post("http://test.com", 200, {method: "POST"});
fetchMock.put("http://test.com", 200, {method: "PUT"});
fetchMock.delete("http://test.com", 200, {method: "DELETE"});

View File

@ -5,6 +5,7 @@
// Risto Keravuori <https://github.com/merrywhether>
// Chris Sinclair <https://github.com/chrissinclair>
// Matt Tennison <https://github.com/matttennison>
// Quentin Bouygues <https://github.com/quentinbouygues>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
@ -120,6 +121,12 @@ declare namespace fetchMock {
* as specified above
*/
matcher?: MockMatcher;
/**
* This option allows for existing routes in a mock to be overwritten.
* Its also possible to define multiple routes with the same matcher.
* Default behaviour is to error
*/
overwriteRoutes?: boolean;
/**
* as specified above
*/