How to test LiveView state/html received via PubSub

Funnily I actually came to this thread because that exact solution to my problem didn’t work. There’s still a race condition because the test process can receive the message before the LiveView process does. My tests tend to fail very rarely on local, but very commonly on CI (via GitHub Actions, not sure exactly what the deal with that is). There are some different solutions proposed in this thread: Testing LiveViews that rely on PubSub for updates, I haven’t tried the :sys.get_state/1 solution but maybe I’ll try writing a different helper with that and see if it’s reliable.

2 Likes