-
Notifications
You must be signed in to change notification settings - Fork 15
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
Update msw to v2 #126
Update msw to v2 #126
Conversation
Hi @YOU54F |
Hey @jakubriedl Thanks for tackling this, nice work. I'm having an OS day today, so I'll put this on my list of things to look at. AFAIK create-react-app is now deprecated or no longer recommended, so I'm happy with removing it entirely and just using a vanilla react app. |
Maybe quick way how to resolve this would be to switch the Example to use Vitest instead of the scripts. It's basically drop-in Jest replacement that actually works and doesn't need any setup and/or quirks. If you ok with that I can do the swap |
So react.dev suggests one of these frameworks now https://react.dev/learn/start-a-new-react-project I did have a go at passing the config through for jest config using this SO q/a
but get compilation errors on the imports,
I'm open to
I'd prefer not to switch to vitest personally, as Jest is well used and supported and has a rich ecosystem, but if it unblocks this migration, then it's not worth me wanting to stick with it, for the sake of an example. |
As an aside for vitest, we had reports of it not working with pact-js here pact-foundation/pact-js#965 (comment) I got a working example today, but it is only simple, so not sure at which point being a drop-in replacement as suggested by the docs, will become stuck, as in theory being a complete drop in replacement is not what the developers are actually striving for. |
@YOU54F I've managed to get the Jest working without ejecting, it isn't beautiful but works now. However migration from CRA to something supported might be good. Can you please check this PR again? |
Added an issue to track the examples update, #127 so we can avoid having to tackle that as part of this PR. Will take a look now my friend! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀 Great work @jakubriedl
Checklist
yarn run dist:ci
passes on my machineDescription
In October 2023 msw released new version 2 that bring significant changes to the msw interface. To reflect these changes
Breaking changes:
MswMatch
is nowMatchedRequest
and is{ request: Request; requestId: string; response: Response }
ExpiredRequest
still called the same and is{ request: Request; requestId: string; startTime: number; duration?: number }
PendingRequest
as{ request: Request; requestId: string; }
PactMswAdapterOptions.providers
function variant is now consistent with msw and has signature(event: PendingRequest) => string | null
PactMswAdapter.emitter
events are slightly updated to match msw behaviourpact-msw-adapter:expired
handler must have signature(event: ExpiredRequest) => void
pact-msw-adapter:match
handler must have signature(event: MatchedRequest) => void
convertMswMatchToPact
is now async function