March 2020
Intermediate to advanced
328 pages
7h 58m
English
LiveView, like Channels, provides test helpers that allow you to quickly write meaningful tests for your LiveView module. The Phoenix.LiveViewTest[67] module provides all the helpers you need to get started writing tests.
Our LiveView is fairly simple because it doesn’t respond to front-end events. Our tests will be basic because of this. We’ll ensure that ProductLiveView mounts, renders the correct HTML, updates when shoes release, and updates when shoes sell out.
To get started, we’ll need to add a test dependency to our mix.exs file. LiveViewTest uses Floki to parse HTML, so let’s add that.
| | {:hound, "~> 1.0"}, |
| | {:floki, ">= 0.0.0", only: :test} |
As always, run mix deps.get ...
Read now
Unlock full access