
arcanemachine
Programming Phoenix LiveView: Thoughts on Chapter 10 ('Test Your Live Views') and potential improvements
I would like to share my thoughts on working through chapter 10 (‘Test Your Live Views’):
-
Because I worked through the previous exercises without updating the tests, many of my tests failed when I arrived at this chapter.
- Suggested mitigation: Warn the user that this may happen, and that we should run only the tests we are working on at the given moment, e.g.
mix test test/pento_web/live/survey_results_live.exs
. (This functionality is used at the bottom of PDF page 305, but I believe it should be explicitly highlighted whenever the tests are to be run.) This will keep the user focused on the task at hand and prevent them from spending time seeing a terminal full of red text (or fixing tests that may have broken as a side effect whatever may have happened while they were working through the book). - Alternative (not as good IMO) mitigation: With each set of exercises, add a bonus exercise about making sure the tests are still passing. I think this solution is less desireable since it detracts from the main point of the book (LiveView, not testing). Also it increases the likelihood of some user-made changes clashing with the material described throughout the book (and of the additional effort of unsnarling their changes and the fixing tests they wrote).
- Suggested mitigation: Warn the user that this may happen, and that we should run only the tests we are working on at the given moment, e.g.
-
As a corollary to the previous point, I think the usage of
mix test
should be described a little more explicitly throughout the chapter. I have only completed the section on unit testing so far, but each step of the book assumes the user already knows how to run the tests. (Which they definitely should. I am not saying they need to have their hand held to the degree that they need to be explained howmix test
works, especially when it has been used earlier in the book, and the book is not an introduction to Elixir or Phoenix.) I believe that the addition of explicit commands such asmix test test/pento_web/live/survey_results_live_test.exs
will help to circumvent the “broken tests” issue I described above.
Marked As Solved

SophieDeBenedetto
Hmm actually now that I’m looking at the chapter, I see that there are no commands that instruct the user to run only mix test
. All instructions tell the user to run the specific test file, and often a specific line number for that test file. I can still add a mention that if the reader does run mix test
though, they may expect some failing tests.
Popular Prag Prog topics










Other popular topics










Latest in PragProg
Latest (all)
Categories:
Popular Portals
- /elixir
- /rust
- /wasm
- /ruby
- /erlang
- /phoenix
- /keyboards
- /js
- /rails
- /python
- /security
- /go
- /swift
- /vim
- /clojure
- /java
- /haskell
- /emacs
- /svelte
- /onivim
- /typescript
- /crystal
- /c-plus-plus
- /tailwind
- /kotlin
- /gleam
- /react
- /flutter
- /elm
- /ocaml
- /vscode
- /opensuse
- /centos
- /ash
- /php
- /deepseek
- /zig
- /scala
- /html
- /debian
- /nixos
- /lisp
- /agda
- /sublime-text
- /textmate
- /react-native
- /kubuntu
- /arch-linux
- /ubuntu
- /revery
- /manjaro
- /spring
- /django
- /diversity
- /nodejs
- /lua
- /slackware
- /c
- /julia
- /neovim