Codemod verified
Regularly tested and maintained by our engineers and codemod expert community.
Msw
migration
byCodemod
Msw/2/Imports
Last update
Jul 24, 2024
Following the original msw upgrade guide, there are certain imports that changed their location and/or naming. This codemod will adjust your imports to the new location and naming.
setupWorker
is now imported frommsw/browser
rest
frommsw
is now namedhttp
RestHandler
frommsw
is now namedHttpHandler
Before
import { rest as caller, RestHandler, setupWorker } from 'msw';const handlers: RestHandler[] = [caller.get('/user', (req, res, ctx) => {return res(ctx.json({ firstName: 'John' }));}),];
After
import { http as caller, HttpHandler } from 'msw';import { setupWorker } from 'msw/browser';const handlers: HttpHandler[] = [caller.get('/user', (req, res, ctx) => {return res(ctx.json({ firstName: 'John' }));}),];
Build custom codemods
Use AI-powered codemod studio and automate undifferentiated tasks for yourself, colleagues or the community