From 0dde12db1ffc484ec00f2f7e208059cbb5df6bdd Mon Sep 17 00:00:00 2001 From: Quentin Bouygues Date: Tue, 6 Mar 2018 14:37:03 +0100 Subject: [PATCH] [fetch-mock] Add Mock Configuration Options --- types/fetch-mock/fetch-mock-tests.ts | 1 + types/fetch-mock/index.d.ts | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/types/fetch-mock/fetch-mock-tests.ts b/types/fetch-mock/fetch-mock-tests.ts index 1d4b706105..84218fb9e1 100644 --- a/types/fetch-mock/fetch-mock-tests.ts +++ b/types/fetch-mock/fetch-mock-tests.ts @@ -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"}); diff --git a/types/fetch-mock/index.d.ts b/types/fetch-mock/index.d.ts index 15babcba34..fc94b18106 100644 --- a/types/fetch-mock/index.d.ts +++ b/types/fetch-mock/index.d.ts @@ -5,6 +5,7 @@ // Risto Keravuori // Chris Sinclair // Matt Tennison +// Quentin Bouygues // 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. + * It’s also possible to define multiple routes with ‘the same’ matcher. + * Default behaviour is to error + */ + overwriteRoutes?: boolean; /** * as specified above */