question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

It's not possible to unit test a WebSocket application

See original GitHub issue

Hi, I’m migrating my Http4s WebSocket application from 1.0.0-M23 to 1.0.0-M34.

Now, as I shouldn’t create a WebSocketBuilder myself, but it is provided by the server, how can I unit test my routes if they require passing a WebSocketBuilder which I can’t create myself?

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
armanbilgecommented, Jul 27, 2022

Making a method public or adding a method is binary compatible. We can take this in 0.23 😃

1reaction
gvolpecommented, Jul 27, 2022

IIUC the main idea behind creating a WebSocketBuilder internally is that it should have the same lifecycle as the HTTP server.

However, as long as the HTTP server builder doesn’t allow the users to use a custom instance, it should be fine to make the constructors public. For example, the current Ember builder takes a function:

def withHttpWebSocketApp(f: WebSocketBuilder2[F] => HttpApp[F]): EmberServerBuilder[F] = ???

If this is the only way to use a WebSocketBuilder and build a WebSocket application, I’d say it doesn’t make sense to hide the constructors from the users, and it will facilitate unit-testing where a server is not involved.

Am I missing some other reason why these constructors have been made private?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why won't unit tests connect to a websocket - Stack Overflow
When I run my unit tests I use the same code to create and run the server (once per test run) my tests...
Read more >
Testing WebSockets for beginners - Scott Logic Blog
We are going to look at the characteristics of WebSockets, what they do, how to test them and investigate the art of the...
Read more >
Writing Integration Tests for WebSocket Servers Using Jest ...
Writing Integration Tests for WebSocket Servers Using Jest and WS. WebSockets are very useful for ongoing communication between a client and a ...
Read more >
Testing Websockets for Redis
Currently it is not possible to simulate more than one client at a time. Django's built in LiveServerTestCase can not handle more than...
Read more >
25. WebSocket Support - Spring
Unlike HTTP, which is an application-level protocol, in the WebSocket protocol there is simply not enough information in an incoming message for a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found