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
feat: support mocking WebSocket APIs #2011
Open
kettanaito
wants to merge
77
commits into
main
Choose a base branch
from
feat/ws
base: main
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains 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
6 tasks
Intentionally pushed failing tests as verification of #2010 (reply in thread). Edit: Removed these. More context in the discussion. |
📦
|
📦
|
📦
|
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.
Roadmap
Extend.Handler
inRequestHandler
. This wayHttpHandler
andGraphQLHandler
will be assignable to typeHandler
, andArray<Handler>
can annotate both HTTP and WebSocket handlersRequestHandler
relies on caching to clone requests, parsed result, etc. Not enough common ground to reuse between it andWebSocketHandler
. WS handler is better off as a standalone class (doesn't supportonce
anyway).handleWebSocketEvent()
inSetupWorkerApi
andSetupServerApi
.instanceof RequestHandler
to skip WebSocket handlers.@mswjs/interceptors
that shipsWebSocketInterceptor
.data
argument of message listeners must be annotated across the board (includes annotating theMessageEvent
in the Interceptors).pnpm test:modules:node
hangs forever onsetupServer()
without the explicitprocess.exit()
in the generatedruntime.*
scripts..use()
override tests (i.e.event.stopImmediatePropagation()
)..start()
/.listen()
calls.server.close()
API (a task for Interceptors, here just add tests).onUnhandledRequest()
(or similar) for unhandled WebSocket connections. Technically, there are no requests, so the existing method reads weird. WebSocket Support Beta #2010 (comment).broadcast()
not broadcasting from N(1) -> N+ but working from N+ -> N+. (discovered in add WebSocket + ws example examples#111) (fix(WebSocketClientManager): use localStorage for clients persistence #2127).this: WebSocket
in theclient
/server
event listeners.localStorage
(fix: fix: purge persisted clients on page reload #2133)