This codemod migrates your project from MSW v1 to v2, handling the breaking changes:
- Updates import statements to new locations and names
- Fixes generic type arguments order
- Modernizes request object usage patterns
- Replaces ctx.fetch() with new fetch(bypass()) pattern
- Updates passthrough method calls
- Converts response patterns to new HttpResponse API
- Updates handler callback signatures
- Modernizes event callback signatures
- Replaces deprecated handler printing methods
Important Notes
⚠️ Custom Factory Functions: This codemod does not change signatures of MSW handlers when called through custom factory functions. You'll need to update these manually.
⚠️ Request Body Usage: If you were using req.body, the codemod assumes you want await request.json(). You may need to adjust for other body types manually.
⚠️ Complete Migration: This codemod performs all necessary transformations in the correct order to ensure your code properly migrates to MSW v2.
Resources
License
MIT