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).
  • 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 how mix 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 as mix test test/pento_web/live/survey_results_live_test.exs will help to circumvent the “broken tests” issue I described above.