Skip to content

Commit bb8d6b4

Browse files
authored
configure msw to blacklist sentry (#652)
* configure msw to blacklist sentry * comment why using msw's onUnhandleRequests using request handler with passthrough requires a more permissible url catching system
1 parent 03b29c1 commit bb8d6b4

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

tests/mocks/index.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,20 @@ import { handlers as resendHandlers } from './resend.ts'
55

66
export const server = setupServer(...resendHandlers, ...githubHandlers)
77

8-
server.listen({ onUnhandledRequest: 'warn' })
8+
server.listen({
9+
onUnhandledRequest(request, print) {
10+
// Do not print warnings on unhandled requests to https://<:userId>.ingest.us.sentry.io/api/
11+
// Note: a request handler with passthrough is not suited with this type of url
12+
// until there is a more permissible url catching system
13+
// like requested at https://github.com/mswjs/msw/issues/1804
14+
if (request.url.includes('.sentry.io')) {
15+
return
16+
}
17+
18+
// Print the regular MSW unhandled request warning otherwise.
19+
print.warning()
20+
}
21+
})
922

1023
if (process.env.NODE_ENV !== 'test') {
1124
console.info('🔶 Mock server installed')

0 commit comments

Comments
 (0)