Msw
migration
byCodemod

Msw/2/Imports

/icons/calendar.svg

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 from msw/browser
  • rest from msw is now named http
  • RestHandler from msw is now named HttpHandler

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

background illustrationGet Started Now