The powerful set of tools in your LiveView testing kit is just one of the many reasons that teams can be so productive in LiveView. This means you can easily test interactions between live views by relying on simple message passing. LiveView is built on top of OTP, and a live view is nothing more than a process. We can use the functions in the LiveViewTest module to apply the same three-step process that guides all of our tests, making it quick and easy to spin up tests for even complex LiveView interactions.
You’ll experience firsthand how to harness that power by working side by side with some of the first LiveView users.
This article showed that the LiveViewTest module provides all the functionality you need to exercise the full range of LiveView interactions in integration tests. LiveView brings the most important programming techniques from the popular Elm and JavaScript React frameworks to Elixir.
You can even use the same elegant reducer pipelines in your tests to verify the behavior of your live view pipelines.
After dabbling around the web finally came across Github example repo of LiveView creator Chris McCord. This provided opportunities for deep unit testing to quickly cover lots of scenarios and edge cases. Got started exploring LiveView and even though there are plenty of resources and tutorial available most of them are outdated as LiveView is version 0.15.x and rapidly changing. In the previous post, we comprised our individual live views from pipelines of single-purpose reducers. LiveView empowers you to write robust and comprehensive tests without a huge investment of engineering effort. Wrap Up: Write Robust and Comprehensive LiveView Tests Our three-step LiveView testing procedure neatly applies to both integration tests that exercise internal live view behavior, and tests that validate the interactions between live view processes. Validated your expectations by asserting that the re-rendered view had some expected content.Provided some input by creating a new rating record and sending a message to the live view with send/2.Established your initial state by mounting and rendering the live view with the call to live/2.sleep ( 2 ) assert render (view) = ~ "2.67" end ) # give the live view time to re-render :timer. AdminDashboardLiveTest do use GamestoreWeb. However, if you're building out a majority of websites (CRUD type pages) that a lot of us web developers do, my personal opinion is that LiveView will be able to everything needed.Defmodule GamestoreWeb. Chris (the speaker in the videos) also notes that if your clients require very good latency or a very complex UI (think Google Sheets) then a JS framework will probably better suit your needs.
While it can update the DOM with data from the server and is very good at doing that, it has limitations such as no offline support. I have spent the last few years working with React / Redux on a big SPA and I believe the entire thing could easily be supported by LiveView we don't do anything fancy, its basically just a bunch of CRUD based pages.Īnother shallow comparison is that LiveView isn't meant to compete with modern progressive SPAs. I can't give a deep comparison since I haven't done anything too deep with LiveView (yet!) but I would encourage you to watch the keynotes on LiveView if you're really interested. Despite being an optional part of Phoenixs web framework, it is becoming increasingly important.