Skip to content

Commit a7e7e1a

Browse files
committed
fix(log): Better logging when no route-match is found
Added a console.warn on missing route-match when fallback is enabled. Logs both http-verb and url regardless of fallback-state #4
1 parent 94d8675 commit a7e7e1a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/yet-another-fetch-mock.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,12 @@ class FetchMock {
7676

7777
if (typeof matchingRoute === 'undefined') {
7878
if (this.configuration.enableFallback) {
79+
console.warn(
80+
`Did not find any matching route for: ${method.toUpperCase()} ${url}. Defaulting to the real fetch-implementation.`
81+
);
7982
response = this.realFetch.call(this.scope, input, init);
8083
} else {
81-
throw new Error(`Did not find any matching route for url: ${url}`);
84+
throw new Error(`Did not find any matching route for: ${method.toUpperCase()} ${url}.`);
8285
}
8386
} else {
8487
pathParams = findPathParams(url, matchingRoute.matcher.matcherUrl);

0 commit comments

Comments
 (0)