Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support MSW 2 #36

Merged
merged 5 commits into from
Nov 16, 2023
Merged

Support MSW 2 #36

merged 5 commits into from
Nov 16, 2023

Conversation

LEI
Copy link
Contributor

@LEI LEI commented Nov 1, 2023

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
Copy link
Owner

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

@LEI
Copy link
Contributor Author

LEI commented Nov 5, 2023

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
Copy link

works great here too, thanks!

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

FIXME: without --node
> No known conditions for "./browser" specifier in "msw" package
@LEI
Copy link
Contributor Author

LEI commented Nov 6, 2023

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

Also rebased changes using pnpm instead of npm.

test/example.spec.ts Outdated Show resolved Hide resolved
@zoubingwu zoubingwu merged commit ebbd6f6 into zoubingwu:master Nov 16, 2023
@LEI LEI deleted the msw-upgrade branch November 16, 2023 19:26
@LEI
Copy link
Contributor Author

LEI commented Nov 16, 2023

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
Copy link

andreyantipov commented Nov 30, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incompatible with msw version 2.0
4 participants