mirror of
https://github.com/hanzoai/msw.git
synced 2026-09-24 17:00:34 +00:00
31 lines
718 B
TypeScript
31 lines
718 B
TypeScript
import { http, HttpResponse } from 'msw'
|
|
import { setupWorker } from 'msw/browser'
|
|
|
|
const worker = setupWorker(
|
|
http.get('/single-cookie', () => {
|
|
return new HttpResponse(null, {
|
|
headers: {
|
|
'Set-Cookie': 'myCookie=value',
|
|
},
|
|
})
|
|
}),
|
|
http.get('/multiple-cookies', () => {
|
|
return new HttpResponse(null, {
|
|
headers: [
|
|
['Set-Cookie', 'firstCookie=yes'],
|
|
['Set-Cookie', 'secondCookie=no; Max-Age=1000'],
|
|
['Set-Cookie', 'thirdCookie=1,2,3'],
|
|
],
|
|
})
|
|
}),
|
|
http.get('/cookies-via-headers', () => {
|
|
const headers = new Headers({
|
|
'Set-Cookie': 'myCookie=value',
|
|
})
|
|
|
|
return new HttpResponse(null, { headers })
|
|
}),
|
|
)
|
|
|
|
worker.start()
|