oliverandrich
How to test PubSub Broadcasts?
Hi,
I am doing my first baby steps with using Phoenix PubSub and added a call to broadcast to the context of my application model. Now I want to extend my test code to check the broadcasting of the message. So far, I found the assert_broadcast helper from Phoenix Channels, but nothing specific to Phoenix PubSub.
How do you test that your code pushes a message to PubSub? I checked various other posts in this forum, but I haven’t found a solution. Or, at least I haven’t understood, that it is the solution.
Best regards,
Oliver
Marked As Solved
oliverandrich
It was easier than I thought. Just discovered assert_receive and refute_received. I just had to call the code to subscribe to the PubSub topic in my testcode.
https://hexdocs.pm/ex_unit/master/ExUnit.Assertions.html#assert_receive/3
Popular in Questions
Other popular topics
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
- #javascript
- #code-sync
- #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
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance








