diff --git a/src/types.ts b/src/types.ts index 508976d..b8e07f5 100644 --- a/src/types.ts +++ b/src/types.ts @@ -57,6 +57,7 @@ export type Middleware = ( export interface Configuration { enableFallback: boolean; + suppressRealFetchWarning: boolean; ignoreMiddlewareIfFallback: boolean; middleware: Middleware; } diff --git a/src/yet-another-fetch-mock.ts b/src/yet-another-fetch-mock.ts index 5bb1a49..2c7eedc 100644 --- a/src/yet-another-fetch-mock.ts +++ b/src/yet-another-fetch-mock.ts @@ -23,6 +23,7 @@ import MockContext from './mock-context'; const defaultConfiguration: Configuration = { enableFallback: true, + suppressRealFetchWarning: false, ignoreMiddlewareIfFallback: false, middleware: (request, response) => response }; @@ -100,9 +101,11 @@ class FetchMock { if (typeof matchingRoute === 'undefined') { if (this.configuration.enableFallback) { - console.warn( - `Did not find any matching route for: ${method.toUpperCase()} ${url}. Defaulting to the real fetch-implementation.` - ); + if (!this.configuration.suppressRealFetchWarning) { + console.warn( + `Did not find any matching route for: ${method.toUpperCase()} ${url}. Defaulting to the real fetch-implementation.` + ); + } response = this.realFetch.call(this.scope, input, init); if (this.configuration.ignoreMiddlewareIfFallback) { return response as Promise;