test: upgrade msw to 2.13 and drop worker.stop() from test fixture#228
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the UI testing stack to accommodate MSW’s worker lifecycle changes introduced in msw@2.13.x, preventing flaky fetch behavior in Vitest browser-mode tests.
Changes:
- Upgraded
mswto2.13.3. - Updated the MSW Vitest fixture to stop calling
worker.stop()after each test. - Refreshed
pnpm-lock.yamlto reflect the new dependency graph.
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/test/msw-test.ts |
Removes per-test worker.stop() teardown to avoid MSW 2.13 lifecycle race. |
package.json |
Bumps msw devDependency range to ^2.13.3. |
pnpm-lock.yaml |
Updates lock entries for msw@2.13.3 and related transitive deps. |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
e5c8ea0 to
3d4c10e
Compare
Deploying rainbow with
|
| Latest commit: |
ba791c9
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://bfd5c009.rainbow-ctx.pages.dev |
| Branch Preview URL: | https://amund-msw-2-13-worker-fix.rainbow-ctx.pages.dev |
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 3 changed files in this pull request and generated no new comments.
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
msw 2.13 shipped a "network source architecture" refactor (mswjs/msw#2650) that altered the worker lifecycle. Our fixture called worker.start() before each test and worker.stop() after, which on 2.13 creates a race: the next test's start() can't take over before requests are made, so they bypass the worker and hit Vite directly — surfacing as "Failed to fetch" and 20s timeouts on every test that makes a request. The upstream fix is to simply not call worker.stop(). This matches the official vitest-browser-mode recipe (https://mswjs.io/docs/recipes/vitest-browser-mode). Tracked upstream at mswjs/msw#2706. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
3d4c10e to
ba791c9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
mswfrom^2.12.14to^2.13.3.worker.stop()from the per-test MSW fixture.Why
msw 2.13.0shipped a network-source-architecture refactor (mswjs/msw#2650) that altered the worker lifecycle. Our fixture calledworker.start()before each test andworker.stop()after, which on 2.13 creates a race — the next test'sstart()can't take over before requests are issued, so they bypass the worker and hit Vite directly. Symptom:Failed to fetchand 20sexpect.polltimeouts on every test that triggers a fetch (~13 UI tests).The upstream fix is simply to not call
worker.stop(). This matches the official vitest-browser-mode recipe:Upstream issue: mswjs/msw#2706.
Test plan
pnpm run test:ui→ 196/196 pass, ~18s (baseline is ~25s)pnpm run test:unitruns via pre-commit hook🤖 Generated with Claude Code