arcanemachine

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).
  • 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.

Marked As Solved

SophieDeBenedetto

SophieDeBenedetto

Author of Programming Phoenix LiveView

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 Top

telemachus
Python Testing With Pytest - Chapter 2, warnings for “unregistered custom marks” While running the smoke tests in Chapter 2, I get these...
New
brianokken
Many tasks_proj/tests directories exist in chapters 2, 3, 5 that have tests that use the custom markers smoke and get, which are not decl...
New
sdmoralesma
Title: Web Development with Clojure, Third Edition - migrations/create not working: p159 When I execute the command: user=> (create-...
New
swlaschin
The book has the same “Problem space/Solution space” diagram on page 18 as is on page 17. The correct Problem/Solution space diagrams ar...
New
jskubick
I think I might have found a problem involving SwitchCompat, thumbTint, and trackTint. As entered, the SwitchCompat changes color to hol...
New
brunogirin
When I run the coverage example to report on missing lines, I get: pytest --cov=cards --report=term-missing ch7 ERROR: usage: pytest [op...
New
AufHe
I’m a newbie to Rails 7 and have hit an issue with the bin/Dev script mentioned on pages 112-113. Iteration A1 - Seeing the list of prod...
New
New
gorkaio
root_layout: {PentoWeb.LayoutView, :root}, This results in the following following error: no “root” html template defined for PentoWeb...
New
mcpierce
@mfazio23 I’ve applied the changes from Chapter 5 of the book and everything builds correctly and runs. But, when I try to start a game,...
New

Other popular topics Top

DevotionGeo
I know that these benchmarks might not be the exact picture of real-world scenario, but still I expect a Rust web framework performing a ...
New
AstonJ
Thanks to @foxtrottwist’s and @Tomas’s posts in this thread: Poll: Which code editor do you use? I bought Onivim! :nerd_face: https://on...
New
Rainer
Not sure if following fits exactly this thread, or if we should have a hobby thread… For many years I’m designing and building model air...
New
AstonJ
In case anyone else is wondering why Ruby 3 doesn’t show when you do asdf list-all ruby :man_facepalming: do this first: asdf plugin-upd...
New
AstonJ
If you are experiencing Rails console using 100% CPU on your dev machine, then updating your development and test gems might fix the issu...
New
New
Margaret
Hello everyone! This thread is to tell you about what authors from The Pragmatic Bookshelf are writing on Medium.
1122 25133 743
New
AstonJ
Saw this on TikTok of all places! :lol: Anyone heard of them before? Lite:
New
First poster: bot
The overengineered Solution to my Pigeon Problem. TL;DR: I built a wifi-equipped water gun to shoot the pigeons on my balcony, controlle...
New
First poster: bot
zig/http.zig at 7cf2cbb33ef34c1d211135f56d30fe23b6cacd42 · ziglang/zig. General-purpose programming language and toolchain for maintaini...
New

Latest in PragProg

View all threads ❯