Skip to content

Commit

Permalink
configure msw to blacklist sentry (#652)
Browse files Browse the repository at this point in the history
* configure msw to blacklist sentry

* comment why using msw's onUnhandleRequests

using request handler with passthrough requires a more permissible url catching system
  • Loading branch information
fredericrous authored Mar 16, 2024
1 parent 03b29c1 commit bb8d6b4
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion tests/mocks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,20 @@ import { handlers as resendHandlers } from './resend.ts'

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

server.listen({ onUnhandledRequest: 'warn' })
server.listen({
onUnhandledRequest(request, print) {
// Do not print warnings on unhandled requests to https://<:userId>.ingest.us.sentry.io/api/
// Note: a request handler with passthrough is not suited with this type of url
// until there is a more permissible url catching system
// like requested at https://github.com/mswjs/msw/issues/1804
if (request.url.includes('.sentry.io')) {
return
}

// Print the regular MSW unhandled request warning otherwise.
print.warning()
}
})

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

0 comments on commit bb8d6b4

Please sign in to comment.