MSW migration recipe

verified codemod icon

This recipe is a set of automations that will upgrade your project from using msw v1 to v2.

MSW
ts-morph
Estimated time saving
Depending on the size of the project, this recipe can save up to 6 hours of dedicated work and more.
Change mode
Assistive
Applicability criteria

MSW version >= 1.0.0

Made by
Intuita
Intuita

Usage →

Intuita CLI:

intalling vs code extension tooltip icon
intuita msw/2/upgrade-recipe
copy CLI command icon

Intuita VS Code extension:

intalling vs code extension tooltip icon
vs code logo
Run in VS Code

Description

This recipe is a set of codemods that will upgrade your project from using msw v1 to v2. The recipe includes the following codemods:

FNs

This recipe does not change the signatures of MSW handlers, if they were called using a custom factory function, for example to provide more type-safety or else. For example, the following code will only be partially updated:

export function mockFactory<T extends MyComplexType>(
  url: string,
  resolver: MyResolverType,
) {
  return rest.get(url, resolver);
}
const handlers = [
  mockFactory('/some/url', (req, res, ctx) => {
    return res(
      ctx.status(200),
    );
  }),
];

Links for more info