alvinlal
how to assert that a particular socket received a particular event in phoenix channel test
if i have a channel test like given below, is it possible to assert that socketA client received a particular event and socketB received a particular event ?
defmodule RockPaperScissorsWeb.GameChannelTest do
use RockPaperScissorsWeb.ChannelCase
test "players get correct results" do
player_id_a = UUID.uuid4()
player_id_b = UUID.uuid4()
game_channel_id = UUID.uuid4()
{_, _, socketA} = joinGameChannel(game_channel_id, player_id_a)
{_, _, socketB} = joinGameChannel(game_channel_id, player_id_b)
push(socketA, "move", %{"player_id" => player_id_a, "move" => "r"})
push(socketB, "move", %{"player_id" => player_id_b, "move" => "r"})
# assert that socketA client received a particular event
# assert that socketB client received a particular event
end
# Helpers
defp joinGameChannel(game_channel_id, player_id) do
RockPaperScissorsWeb.Socket
|> socket(nil, %{})
|> subscribe_and_join(
RockPaperScissorsWeb.GameChannel,
"game:#{game_channel_id}",
%{"player_id" => player_id}
)
end
end
Popular in Questions
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set?
Thanks.
New
I have VueJS GUIs with the project generated using Webpack.
I have Elixir modules that will need to be used by the VueJS GUIs.
I forese...
New
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this:
...
New
Using vs code and installed ElixirLS: support and debugger.
And I got an error popped up on start up says
Failed to run ‘elixir’ comma...
New
Other popular topics
Hi guys, i’m new in the Elixir world, and i have to say, that i love it!
i’m having some problem to understand anonymous functions with ...
New
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something…
Haskell reminds me of Java, and e...
New
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
New
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
i’m a new one to elixir
which editor can i use
vs code? or atom?
Thanks! :smiley:
New
Posting this to see if we can make things easier for people to get into Neovim. If you use Neovim and have a favourite distro please let ...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #hex









