Websocket is undefined
See original GitHub issueHi, i have a problem when testing my component using mocha & chai, it says:
ReferenceError: WebSocket is not defined
at module.exports.r.open (/Users/bcw-001/dev/sofia_fe_react/node_modules/sockette/src/index.js:25:32)
at new module.exports (/Users/bcw-001/dev/sofia_fe_react/node_modules/sockette/src/index.js:48:7)
i use mock-websocket. anyone know what did i miss?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:8 (4 by maintainers)
Top Results From Across the Web
JavaScript - ReferenceError: WebSocket is not defined
It seems like @stomp/stompjs is not the only package with a missing dependency on Websocket. In my case it was fast-xml-parser (or one...
Read more >ReferenceError: WebSocket is not defined · Issue #11 - GitHub
I am getting following error while using this library on nodejs, I am new to this can help me to resolve this. ReferenceError:...
Read more >node_modules/lib0/websocket.js:25:23 - Yjs Community
I'm having this issue: (base) raphy@pc:~/y-webrtc-playing$ node ./bin/server.js Signaling server running on localhost: 5555 (base) ...
Read more >WebSocket.send() - Web APIs - MDN Web Docs - Mozilla
The WebSocket.send() method enqueues the specified data to be transmitted to the server over the WebSocket ... None ( undefined ).
Read more >Websocket data undefined outside onmessage block
I have a variable called data and I initialize it with the json from the websocket. It is displayed in the console inside...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
No problem~!
You shouldn’t modify any
node_modules/**
code – all your changes will be immediately lost anytime you install another dependency or if/when a coworker tries to replicate your setup.Instead, you should do this in your testing setup file, or at the top of test files (repetitive):
Hey @tinchoz49 👋
No I would not, sorry. It would be meaningless to Sockette. You should simply do this instead:
This would only be set in your Node.js environment, leaving
window.WebSocket
intact for your browser bundle(s). If that’s not the case, then you will need to take a closer look at your build config because you should never have server code/deps in your front-end bundles. I can maybe help with this part if you have questions or issues.The above will give you full support 👍