Skip to content
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

Supported WebSocket implementations #1195

Closed
rgbkrk opened this issue Aug 15, 2015 · 31 comments
Closed

Supported WebSocket implementations #1195

rgbkrk opened this issue Aug 15, 2015 · 31 comments

Comments

@rgbkrk
Copy link

rgbkrk commented Aug 15, 2015

There's code we want to be able to test with JSDom that uses websockets. There are a lot of different implementations. Which would you suggest for use in contexts server side in JSDom + client side in the browser? I'm leaning towards ws.

@Joris-van-der-Wel
Copy link
Member

Well, if you are wondering about integration into jsdom, my vote would go to one that:

  • is well maintained
  • has no binary dependencies
  • implements the api per spec

@domenic
Copy link
Member

domenic commented Aug 15, 2015

In particular, ws definitely does not implement the spec API, e.g. using on instead of addEventListener and so on.

I'm a little unclear what the purpose of this question is. Are you preparing to create a PR to add web socket support to jsdom?

@domenic domenic closed this as completed Sep 14, 2015
@rgbkrk
Copy link
Author

rgbkrk commented Sep 14, 2015

I'd create a PR to add websocket support if you'd want it. For code that I'm testing using JSDom, I also want to be able to test websockets (while being able to browserify the whole lot).

@domenic
Copy link
Member

domenic commented Sep 14, 2015

That would be lovely!

@rgbkrk
Copy link
Author

rgbkrk commented Sep 14, 2015

Would it be appropriate to use ws under the hood, but make the API match the API specification for websockets?

@domenic
Copy link
Member

domenic commented Sep 14, 2015

Definitely.

@avesus
Copy link

avesus commented Dec 23, 2015

What the purpose of JSDom in XI century if it doesn't support WebSockets?..
:-)
@rgbkrk +1
@domenic have you integrated the PR?

@domenic
Copy link
Member

domenic commented Dec 23, 2015

@avesus It turns out a lot of people find purpose in it so far despite it not being a complete browser.

have you integrated the PR?

What PR?

@rgbkrk
Copy link
Author

rgbkrk commented Dec 23, 2015

I never made a PR, ended up getting away from jsdom for a bit as well as the project I wanted websockets for. Back to using it again though!

@domenic
Copy link
Member

domenic commented Apr 11, 2016

Please use the voting buttons and don't add "me too" comments. Deleting the one that just appeared.

@davidworkman9
Copy link

Voting buttons? I'm looking around for this, found a change petition but it appears that github has not implemented any voting system..

@inikulin
Copy link
Contributor

@davidworkman9
image

@davidworkman9
Copy link

@inikulin thanks. I was not aware that in github land that reaction.meaning == vote.meaning (or that you could use reactions as a voting mechanism). Sorry about my lack of proper github social skills.

@rgbkrk
Copy link
Author

rgbkrk commented Apr 12, 2016

Hey it's ok, the feature has only been around a few weeks IIRC.

@alexey2baranov
Copy link

what is the current state of websocket in jsdom?

@Sebmaster
Copy link
Member

It's not implemented.

@alexey2baranov
Copy link

@Sebmaster
It is very hard to separate out code from websockets. We would like to test views but views require models, models require websockets. Moking models is possible but very close test range.

Do you plan to implement websokets in near future?

@Sebmaster
Copy link
Member

I don't think anyone of us is currently implementing it, or prioritizing it in the near future. So unless there's a PR or a change of priorities, probably not.

@palmerj3
Copy link

palmerj3 commented Sep 5, 2017

Is anyone interested in collaborating on this?

I'm willing to do the work but would be great to have others participate at least in reviews.

@TimothyGu
Copy link
Member

@palmerj3 I'd be interested, but I'm sure the rest of @jsdom would be too. Just make sure to look at the requirements @Joris-van-der-Wel listed out when choosing a WS library: #1195 (comment). If you hit any bumps, we'll be on #jsdom at Freenode to help :)

@thdxr
Copy link

thdxr commented Dec 5, 2017

Is anyone working on this? Will take a crack at it otherwise

@rgbkrk
Copy link
Author

rgbkrk commented Dec 5, 2017

No one is working on this. ws does support addEventListener now so you should be able to use that module directly.

@domenic
Copy link
Member

domenic commented Dec 5, 2017

In general we're not able to use any modules directly as they don't support the full Web IDL semantics; wrapping will still be necessary. See https://github.com/tmpvar/jsdom/blob/master/Contributing.md#architecture for more information.

@thdxr
Copy link

thdxr commented Dec 5, 2017

Would using this not work? https://www.npmjs.com/package/universal-websocket-client

This is actually what I'm using in my application that jsdom is having issues with

@domenic
Copy link
Member

domenic commented Dec 5, 2017

That definitely wouldn't be a good idea; it's just a wrapper around ws, so we'd then need a wrapper around a wrapper around ws. Let's just do one layer of wrapping, please.

@thdxr
Copy link

thdxr commented Dec 5, 2017

AFAIK this wrapper does implement this spec API

@domenic
Copy link
Member

domenic commented Dec 5, 2017

Yes, but as I tried to explain (and Contributing.md goes into in more detail), it doesn't implement it in a way that's compatible with jsdom's systems. For example, jsdom already contains an EventTarget, so we can't use the one that ws (or universal-websocket-client) comes with; then we'd have duplicates.

@thdxr
Copy link

thdxr commented Dec 5, 2017

Ah that makes sense. Will dig into the contributing docs. Thanks

@rgbkrk
Copy link
Author

rgbkrk commented Dec 6, 2017

Thanks @domenic and @thdxr.

@TimothyGu
Copy link
Member

FYI there is now an active PR implementing the entirety of the WebSocket APIs, in #2088. Please, check it out!

@TimothyGu
Copy link
Member

The WebSocket API PR just got merged! Support will be available in the next jsdom release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests