Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import { setupWorker, rest } from 'msw'
export const mocks = [
rest.get('https://hoge.com/users/:user', (req, res, ctx) => {
const { user } = req.params
return res(
ctx.status(200),
ctx.json({
name: `mocked-${user}`,
}),
)
}),
]
const worker = setupWorker(...mocks)
worker.start()
export { worker, rest }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment