Skip to content

Instantly share code, notes, and snippets.

@ksakae1216
Created September 19, 2022 01:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ksakae1216/a2b56d78668d21d2e92dc5bd35ea18d3 to your computer and use it in GitHub Desktop.
Save ksakae1216/a2b56d78668d21d2e92dc5bd35ea18d3 to your computer and use it in GitHub Desktop.
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