msw#setupWorker TypeScript Examples
The following examples show how to use
msw#setupWorker.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: browser.tsx From posthog-foss with MIT License | 5 votes |
worker = setupWorker(
// For /e/ let's just return a 200, we're not interested in mocking this any further
rest.post('/e/', (_, res, ctx) => res(ctx.status(200))),
// For everything else, require something explicit to be set
rest.get('/api/*', (_, res, ctx) => res(ctx.status(500), ctx.text('No route registered'))),
rest.post('/api/*', (_, res, ctx) => res(ctx.status(500), ctx.text('No route registered'))),
rest.put('/api/*', (_, res, ctx) => res(ctx.status(500), ctx.text('No route registered'))),
rest.delete('/api/*', (_, res, ctx) => res(ctx.status(500), ctx.text('No route registered')))
)