-
-
Notifications
You must be signed in to change notification settings - Fork 606
feat: use the network source architecture (defineNetwork)
#2650
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
Merged
Merged
Changes from 104 commits
Commits
Show all changes
116 commits
Select commit
Hold shift + click to select a range
fc8c4ba
feat(wip): implement the `defineNetwork` API
kettanaito 30f32a8
fix(ws): implement the handler lookup handling
kettanaito f65e91d
fix: implement `setupServer` and `SetupServerCommonApi`
kettanaito 2b64a7f
fix: implement `setupWorker`
kettanaito 980f4be
chore: remove legacy `msw/node` apis
kettanaito 92d4fb7
chore: comment on the `WebSocketInterceptor` type error
kettanaito 28d69b4
fix: annotate network frames on source level as unknown
kettanaito c7bc89e
chore: use instanceof checks for frame handling
kettanaito 9caaf66
chore: ignore `BatchInterceptor` listener type inference issue
kettanaito 3f4b90f
chore: do not reference `~/core` in core
kettanaito d3659be
chore: use `rettime` for life cycle events
kettanaito 2ee72e3
fix(ts): infer event maps from network sources
kettanaito c47b26f
chore: remove old `setupWorker`
kettanaito 1a9a94b
chore: use `#core` import alias
kettanaito 2d33af0
fix(setupWorker): add node.js environment check
kettanaito bfbe16c
chore: fix some tests
kettanaito 12ddb9f
fix(onUnhandledFrame): check for common assets after function check
kettanaito 48160ec
fix: use node 24, surface lookup errors
kettanaito 7e2bf32
chore: fix type issues, run on node 22
kettanaito 36d8f5a
fix(setupWorker): print stop message on `.disable()`
kettanaito cb28c95
fix(defineNetwork): merge `controller` and `handlers` options
kettanaito fd3776e
chore(setupWorker): reorder imports
kettanaito 99cc047
fix(setupWorker): forward start options to service worker source
kettanaito 6359d63
fix(setupWorker): print `worker.scriptURL` in the start message
kettanaito 570a2ac
fix(defineNetwork): implement `.configure()` for late config options
kettanaito 9ce2912
chore: fix signature overload type error by updating `rettime`
kettanaito a5e09f2
chore: fix formatting issues
kettanaito e289a7b
fix(defineNetwork): create handlers controller immediately
kettanaito 4b26dbf
fix(setupWorker): print start message in `start`, add redundant start…
kettanaito 8a8c121
fix(setupWorker): skip the start message in quiet mode
kettanaito fc62bed
Merge branch 'main' into fix/define-network
kettanaito 4255969
test: remove `not.toBeAny` assertions from `define-network` tests
kettanaito 29032f3
feat(handlers): store handlers as a kind-based map
kettanaito 5534df7
fix: export `defaultNetworkOptions` from `/node` and `/native`
kettanaito 87239cf
chore: fix formatting linting errors
kettanaito 9bc1223
fix: export new apis under `msw/future`
kettanaito c85308b
chore: rename `new` to `future`
kettanaito 4c8dd58
fix(worker): formatting of the integrity check
kettanaito 0c77bfb
fix(worker): use `ResponseEvent` for life-cycle events
kettanaito a5b7c21
fix(WebSocketFrame): implement custom `WebSocketConnectionEvent`
kettanaito 61e5443
fix(worker): return worker registration from `start`
kettanaito 00ba8ba
fix(worker): dispatch "msw:worker/stop" on `stop`
kettanaito d676202
fix: forward `quiet` onto handled resolution context
kettanaito 6572d07
Merge branch 'main' into fix/define-network
kettanaito 061c3a6
chore: implement print start/stop messages as methods of sources
kettanaito 570ad2d
fix(http-frame): emit `request:end` for bypassed requests
kettanaito 847c837
fix(sw-source): set `url` on the response instance
kettanaito 4985c5f
fix(setupWorker): dispatch `msw/worker:stop` after disabling network
kettanaito d6b6cb3
fix(setupWorker): support passthrough after stop
kettanaito 56d48b7
test: refactor ws.clients test
kettanaito e2af5aa
fix(setupWorker): simplify the handler exception error message
kettanaito ea91f99
fix(setupWorker): add redundant `worker.stop()` warning
kettanaito 4fefde8
Merge branch 'main' into fix/define-network
kettanaito 96719b9
fix(setupWorker): add deprecated `waitUntilReady` start option
kettanaito 56e59ab
fix(ws): attach logger before `connection` is emitted
kettanaito ed5e2ff
fix: execute unhandled frame handle as a part of `frame.resolve`
kettanaito 31fe40f
fix(worker): add missing worker scope validation
kettanaito 3b27f59
test(iframe): fix flaky test
kettanaito b7569e6
test(in-flight): polish the test
kettanaito e3c9560
fix(worker): do not call `super.disable()` to handle in-flight requests
kettanaito 7e00faa
fix(worker): add a slight negative delay to `interceptedAt`
kettanaito b0c0e5f
test(post-formdata): simplify the test case
kettanaito 6ae4a5e
chore: rename `/future` to `/experimental`
kettanaito 98a53e9
fix(ws): iterate over `handlers` via `for` to propagate `kConnect` ex…
kettanaito 5cc920c
fix(worker): remove `interceptedAt` compensation, improve test
kettanaito a4be9ac
test: add exception handling node.js tests
kettanaito b4539da
test: use `expect.fail`
kettanaito 392665b
chore: polish, `NetworkFrameEvent`
kettanaito 70d7f60
fix: revert `engines` in `package.json`
kettanaito c4c968f
fix: export http/ws event map types from `experimental`
kettanaito 901f76f
test(onUnhandledFrame): add unit tests
kettanaito 8971589
test: add tests for `request-utils`
kettanaito 69b14d5
docs: add jsdoc blocks for the new apis
kettanaito c07b276
test(http-frame): add unit tests
kettanaito 6bd04d6
fix(WebSocketFrame): forward unhandled exceptions in the `unhandledEx…
kettanaito e63d350
chore: migrate `node-websocket` environment to vitest 4
kettanaito 3bcdac3
test(resetHandlers): replace external urls with localhost
kettanaito 2f858e6
fix(WebSocketFrame): replace `#core` with relative import
kettanaito 6401efa
test(network-source): add unit tests
kettanaito 803fdcc
chore: move `getHandlerKindByFrame` to `network-frame.ts`
kettanaito f0b94a9
fix: let frames decide handlers (`.getHandlers()`)
kettanaito ba3525b
chore: remove empty `network-frame.test.ts`
kettanaito 416105b
test(resetHandlers): fix non-matching requests assertions
kettanaito 1fce251
fix(WebSocketFrame): throw caught errors
kettanaito 45fe765
test(WebSocketFrame): adjust assertions per exception forwarding
kettanaito bd8f397
Merge branch 'main' into fix/define-network
kettanaito a28f915
Merge branch 'main' into fix/define-network
kettanaito ffb59d3
fix(HandlersController): call `setState()` in `use()`
kettanaito d656bfe
fix(HandlersController): remove dead ternary branch
kettanaito c4973c8
fix(defineNetwork): remove frame event listeners on `disable()`
kettanaito 9e505c2
Merge branch 'main' into fix/define-network
kettanaito f243e5c
fix: revert `currentHandlers` to a method for backward compatibility
kettanaito da20797
fix: ensure `RequestHandler` type is accepted in setup functions (#2676)
felmonon d7dbd43
Merge branch 'main' into fix/define-network
kettanaito 4a9fce1
fix(AsyncHandlersController): add `boundary` method
kettanaito 468a87b
Merge branch 'main' into fix/define-network
kettanaito c9e4c17
test(handlers-controller): add reset->use->reset test case
kettanaito fb16121
fix(network-source): accept `options` for `.on()`
kettanaito 47b4346
fix(defineNetwork): infer return type of enable/disable from network …
kettanaito 20f9bca
fix: improvements
kettanaito 399578f
fix(http-frame): emit `request:match` for matched passthrough
kettanaito 8a56681
test(resetHandlers): perform correct request in tests
kettanaito 544bdf5
fix(setupWorker): reset `isStarted` to prevent redundant start warnin…
kettanaito f9c706c
fix(setupWorker): print an error if stopping throws
kettanaito a41926b
chore: fix matched passthrough events assertion
kettanaito ded4be6
fix(setupWorker): print redundant stop() call warning
kettanaito a8dd0ec
fix(serviceWorkerSource): delete frame after reading it
kettanaito 8d34dc7
test: add `request:match` to passthrough with matching handler
kettanaito b84b253
fix: export `SetupWorkerApi` as a class
kettanaito 9b2a005
test(defineNetwork): add colorless enable/disable unit tests
kettanaito 29067f5
chore: add `#core/*` import
kettanaito 28dab35
fix(defineNetwork): add `readyState`, throw on enable-after-enable an…
kettanaito a10e19c
fix(setupWorker): make `stop()` fully synchronous
kettanaito fce9163
fix(service-worker-source): handle unknown throwables
kettanaito b228332
fix: rely on native dts resolution for `./experimental`
kettanaito 3dc3fc0
Merge branch 'main' into fix/define-network
kettanaito File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| v20 | ||
| v22 |
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,2 @@ | ||
| export { setupWorker } from './setupWorker/setupWorker' | ||
| export type { SetupWorker, StartOptions } from './setupWorker/glossary' | ||
| export { SetupWorkerApi } from './setupWorker/setupWorker' | ||
| export { setupWorker, type SetupWorkerApi } from './setup-worker' | ||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| export type { SetupWorker, StartOptions } from './glossary' | ||
6 changes: 2 additions & 4 deletions
6
...wser/setupWorker/setupWorker.node.test.ts → src/browser/setup-worker.node.test.ts
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.