Starting our channel tests

We'll also want to finish up by writing some appropriate tests for our channels. We'll create test/vocial_web/channels/polls_channel_test.exs and start off by declaring our test module, including the appropriate set of testing macros and alias statements:

defmodule VocialWeb.PollChannelTest do  use VocialWeb.ChannelCase  alias VocialWeb.PollsChannelend

Similar to our controller tests, we'll also need to create a nice big setup block that will create a user account that we can use:

  setup do    {:ok, user} = Vocial.Accounts.create_user(%{      username: "test",      email: "test@test.com",      password: "test",      password_confirmation: "test"    })

We'll also need to make a pre-created poll:

 {:ok, poll} = Vocial.Votes.create_poll_with_options( ...

Get Phoenix Web Development 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.