File tree Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -57,6 +57,7 @@ export type Middleware = (
5757
5858export interface Configuration {
5959 enableFallback : boolean ;
60+ suppressRealFetchWarning : boolean ;
6061 ignoreMiddlewareIfFallback : boolean ;
6162 middleware : Middleware ;
6263}
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ import MockContext from './mock-context';
2323
2424const defaultConfiguration : Configuration = {
2525 enableFallback : true ,
26+ suppressRealFetchWarning : false ,
2627 ignoreMiddlewareIfFallback : false ,
2728 middleware : ( request , response ) => response
2829} ;
@@ -100,9 +101,11 @@ class FetchMock {
100101
101102 if ( typeof matchingRoute === 'undefined' ) {
102103 if ( this . configuration . enableFallback ) {
103- console . warn (
104- `Did not find any matching route for: ${ method . toUpperCase ( ) } ${ url } . Defaulting to the real fetch-implementation.`
105- ) ;
104+ if ( ! this . configuration . suppressRealFetchWarning ) {
105+ console . warn (
106+ `Did not find any matching route for: ${ method . toUpperCase ( ) } ${ url } . Defaulting to the real fetch-implementation.`
107+ ) ;
108+ }
106109 response = this . realFetch . call ( this . scope , input , init ) ;
107110 if ( this . configuration . ignoreMiddlewareIfFallback ) {
108111 return response as Promise < Response > ;
You can’t perform that action at this time.
0 commit comments