Search⌘ K
AI Features

How to Verify Distributed Realtime Updates

Understand how to test PubSub-based real-time updates in Phoenix LiveView by sending messages to LiveView processes, rendering views, and asserting UI updates. This lesson guides you through verifying distributed realtime functionality in a LiveView admin dashboard.

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.

Setting up the test

The real-time survey results chart test will follow the same LiveView test pattern we used ...