Testing Phoenix Channels

At this point, we've covered unit and integration testing. Now, we'll explore how to create tests for the Phoenix Channels we created in the last chapter. This is not a type of testing per se, but it's still important to explore on its own, as it comes bundled with its own set of helpers.

As we've seen in the last chapter, connecting to a channel is a two-step procedure: we first connect to the socket (through the UserSocket module, in our case) to establish a connection with the server; then, after having a socket connected to the server, we use it to join the channels we're interested in. Therefore, we will have two test cases in this section: one for the UserSocket module, where we'll test that this module handles ...

Get Mastering Elixir now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.