zoubingwu / msw-auto-mock

A cli tool to generate random mock data from OpenAPI definition for msw.
246 stars 54 forks source link

Support MSW 2 #36

Closed LEI closed 7 months ago

LEI commented 8 months ago

Here is an attempt to migrate the template to work with MSW 2.0 according to https://mswjs.io/docs/migrations/1.x-to-2.x/ that may close #35, or at least help in the meantime.

Also added a regression test verifying the examples are valid (first commit works on 0.15.0).

Since this is a breaking change, I guess the version should be updated too. It might require more testing.

zoubingwu commented 8 months ago

wow, thanks for you work! I'll look into it asap

LEI commented 8 months ago

Thanks for this tool!

This has been tested on a real Node.js project, also added a React Native test but I don't use it personally.

Examples using msw/browser fail probably because tests run in a Node.js environment:

Error: promise rejected "Error: No known conditions for "./browser" specifier in "msw" package" instead of resolving

Briaoeuidhtns commented 8 months ago

works great here too, thanks!

one note, it's best to not go backwards in version numbers, it'll cause issues with some tools

LEI commented 8 months ago

Thanks @Briaoeuidhtns, good point, deleted the version change commit.

Also rebased changes using pnpm instead of npm.

LEI commented 7 months ago

The test is failing in CI because ./dist/cli.js is missing. I guess a build step could be added in the workflow or the test could use the library directly.

andreyantipov commented 7 months ago

Hi, any plans to release this as npm package for msw 2.0?