Skip to content

Commit 2ba444c

Browse files
committed
smarter warning suppression for unhandled routes in msw
1 parent 0de4210 commit 2ba444c

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

app/msw-mock-api.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,8 @@ export async function startMockAPI() {
8484
// pass through to the server
8585
onUnhandledRequest(req) {
8686
const path = new URL(req.url).pathname
87-
// Files that get pulled in dynamic imports. It is expected that MSW will
88-
// not handle them and they fall through to the dev server, so warning
89-
// about them is just noise.
90-
const ignore = [
91-
path.startsWith('/app'),
92-
path.startsWith('/libs'),
93-
path.startsWith('/node_modules'),
94-
].some(Boolean)
95-
if (!ignore) {
87+
// only warn on unhandled requests that are actually to API paths
88+
if (path.startsWith('/v1/')) {
9689
// message format copied from MSW source
9790
console.warn(`[MSW] Warning: captured an API request without a matching request handler:
9891

0 commit comments

Comments
 (0)