How to Verify Distributed Realtime Updates
Let's learn how to verify testing results in a Phoenix application.
We'll cover the following
Testing message passing in a distributed application can be painful, but LiveViewTest
makes it easy to test the PubSub-backed real-time features we’ve built into our admin dashboard. That is because LiveView tests interact with views via process communication. Because PubSub uses simple Elixir message passing, testing a LiveView’s ability to handle such messages is a simple matter of using send/2
.
In this lesson, we’ll write a test to verify the admin dashboard’s real-time updates that fire when it receives a "rating_created"
message. We’ll use a call to send/2
to deliver the appropriate message to the view and then use the render
function to test the result.
Get hands-on with 1400+ tech skills courses.