Open vaughnkoch opened 9 months ago
Hi, @vaughnkoch. According to the details, you are using 3 libraries and one of them has a conflict with the api. So right now it’s hard to say what’s the real reason of it.
Can you please create a minimal repo or share a snippet of how to reproduce it?
Hi, I opened an issue in
jest-websocket-mock
; the maintainer said I should reopen the issue inmock-socket
. See https://github.com/romgain/jest-websocket-mock/issues/169#issuecomment-1916434899.Original issue text (slightly edited, and with added
mock-socket
version):I'm trying to use
jest-websocket-mock
andmock-socket
in conjunction withpartysocket
, which seems like the most updated browser WebSocket library right now: https://docs.partykit.io/reference/partysocket-api/.When I run my tests and I use
jest-websocket-mock
/mock-socket
to send a message, I get this error: this error:TypeError: ports is not iterable
.Here's what I do in my tests:
Then,
mock-socket
creates the message from this function:Then
partysocket
clones the event with this code (it actually uses cloneEventNode because Jest is running in the node environment).The above code fails on this line:
I looked at the
e
parameter ande.ports
, isnull
which explains the error. This may be because of a different environment, but do you have any suggestions on how to fix this?Note: I also tried to force the environment to Node (instead of the browser), but got this cryptic error:
Versions: