-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upgrade to MSW 2.0 #1809
Upgrade to MSW 2.0 #1809
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
libs/api-mocks/msw/handlers.ts
Outdated
@@ -63,7 +64,7 @@ export const handlers = makeHandlers({ | |||
} | |||
db.projects.push(newProject) | |||
|
|||
return json(newProject, { status: 201 }) | |||
return HttpResponse.json(newProject, { status: 201 }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn’t say no to cutting this diff down by doing const json = HttpResponse.json
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Took a big of finagling but I got it to work. Diff is definitely smaller now.
For historical context, @david-crespo and I spent all of yesterday trying to debug an issue where E2E tests were failing in safari due to this browser error
We traced it down to a bug in a safari work around in MSW which was causing an empty array buffer to be passed to the I've worked around the issue in Also, note to our future selves: console logs and debug output for service workers on safari are shuttled off to a different devtools instance hidden in the developer menu. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome. The Firefox E2E failure is likely due to GH's current outages.
oxidecomputer/console@bd65b9d...ae8218d * [ae8218df](oxidecomputer/console@ae8218df) bump msw to 2.0.3 for the real safari fix * [9a3f95a9](oxidecomputer/console@9a3f95a9) reduce dev console noise about local assets not served by MSW * [a61ecf24](oxidecomputer/console@a61ecf24) oxidecomputer/console#1809 * [50f3a5b2](oxidecomputer/console@50f3a5b2) bump recharts and react query * [1a2b5656](oxidecomputer/console@1a2b5656) oxidecomputer/console#1808 * [4c01cd68](oxidecomputer/console@4c01cd68) oxidecomputer/console#1800 * [57cc1892](oxidecomputer/console@57cc1892) oxidecomputer/console#1802 * [47d76dbf](oxidecomputer/console@47d76dbf) oxidecomputer/console#1806 * [eee0eb2e](oxidecomputer/console@eee0eb2e) oxidecomputer/console#1805 * [60c2285e](oxidecomputer/console@60c2285e) oxidecomputer/console#1804 * [d9cf1ef1](oxidecomputer/console@d9cf1ef1) bump sort imports plugin for vuln * [ba3a383e](oxidecomputer/console@ba3a383e) bump playwright to 1.39 (fix issue with z-index test)
### User-facing fixes * [57cc1892](oxidecomputer/console@57cc1892) oxidecomputer/console#1802 * [47d76dbf](oxidecomputer/console@47d76dbf) oxidecomputer/console#1806 * [60c2285e](oxidecomputer/console@60c2285e) oxidecomputer/console#1804 ### Full summary oxidecomputer/console@bd65b9d...ae8218d * [ae8218df](oxidecomputer/console@ae8218df) bump msw to 2.0.3 for the real safari fix * [9a3f95a9](oxidecomputer/console@9a3f95a9) reduce dev console noise about local assets not served by MSW * [a61ecf24](oxidecomputer/console@a61ecf24) oxidecomputer/console#1809 * [50f3a5b2](oxidecomputer/console@50f3a5b2) bump recharts and react query * [1a2b5656](oxidecomputer/console@1a2b5656) oxidecomputer/console#1808 * [4c01cd68](oxidecomputer/console@4c01cd68) oxidecomputer/console#1800 * [57cc1892](oxidecomputer/console@57cc1892) oxidecomputer/console#1802 * [47d76dbf](oxidecomputer/console@47d76dbf) oxidecomputer/console#1806 * [eee0eb2e](oxidecomputer/console@eee0eb2e) oxidecomputer/console#1805 * [60c2285e](oxidecomputer/console@60c2285e) oxidecomputer/console#1804 * [d9cf1ef1](oxidecomputer/console@d9cf1ef1) bump sort imports plugin for vuln * [ba3a383e](oxidecomputer/console@ba3a383e) bump playwright to 1.39 (fix issue with z-index test)
The v1 to v2 migration guide can be found here.
This PR depends on oxidecomputer/oxide.ts#215
Most of the changes here are fairly mechanical like renaming the
rest
export frommsw
tohttp
. The biggest change is the removal of the compositionalreq
API from MSW which was a pseudo request object with extra metadata associate with it and the ability to compose utility functions on top of it. It now uses the standardRequest
object which includes some immediate tradeoffs like not havingcookies
hanging off of it. Cookies are now passed to the handler and have to be piped down through the rest of the call chain. Given the removal of the compositional API, utilities likedelay
are now stand alone functions which necessitates actually being able to write async handlers. I've wrapped all the handlers intype-fest
'sPromisable
(T | Promise<T>
) and we were actually already awaiting the results so no changes were needed there.Overall, not too bad. Just remember to use
HttpResponse
for normal responses. I've also included ajson
helper export from the generated API to cut down on the diff as suggested.