mirror of
https://github.com/hanzoai/msw.git
synced 2026-09-24 17:00:34 +00:00
25 lines
593 B
TypeScript
25 lines
593 B
TypeScript
import { http } from 'msw'
|
|
import { setupWorker } from 'msw/browser'
|
|
|
|
const worker = setupWorker(
|
|
http.get('/user', () => {
|
|
return new Response()
|
|
}),
|
|
)
|
|
|
|
Object.assign(window, {
|
|
msw: {
|
|
registration: worker
|
|
.start({
|
|
// This is the default matching behavior if left unspecified.
|
|
findWorker(scriptURL, mockServiceWorkerUrl) {
|
|
return scriptURL === mockServiceWorkerUrl
|
|
},
|
|
})
|
|
.then((registration) => {
|
|
console.log('Registration Promise resolved', registration)
|
|
return registration?.constructor.name
|
|
}),
|
|
},
|
|
})
|