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 Pragmatic topics Top

jon
Some minor things in the paper edition that says “3 2020” on the title page verso, not mentioned in the book’s errata online: p. 186 But...
New
Mmm
Hi, build fails on: bracket-lib = “~0.8.1” when running on Mac Mini M1 Rust version 1.5.0: Compiling winit v0.22.2 error[E0308]: mi...
New
AleksandrKudashkin
On the page xv there is an instruction to run bin/setup from the main folder. I downloaded the source code today (12/03/21) and can’t see...
New
rmurray10127
Title: Intuitive Python: docker run… denied error (page 2) Attempted to run the docker command in both CLI and Powershell PS C:\Users\r...
New
jskubick
I’m under the impression that when the reader gets to page 136 (“View Data with the Database Inspector”), the code SHOULD be able to buil...
New
digitalbias
Title: Build a Weather Station with Elixir and Nerves: Problem connecting to Postgres with Grafana on (page 64) If you follow the defau...
New
taguniversalmachine
Hi, I am getting an error I cannot figure out on my test. I have what I think is the exact code from the book, other than I changed “us...
New
creminology
Skimming ahead, much of the following is explained in Chapter 3, but new readers (like me!) will hit a roadblock in Chapter 2 with their ...
New
dachristenson
@mfazio23 Android Studio will not accept anything I do when trying to use the Transformations class, as described on pp. 140-141. Googl...
New
dachristenson
I’ve got to the end of Ch. 11, and the app runs, with all tabs displaying what they should – at first. After switching around between St...
New

Other popular topics Top

AstonJ
If it’s a mechanical keyboard, which switches do you have? Would you recommend it? Why? What will your next keyboard be? Pics always w...
New
malloryerik
Any thoughts on Svelte? Svelte is a radical new approach to building user interfaces. Whereas traditional frameworks like React and Vue...
New
DevotionGeo
I know that -t flag is used along with -i flag for getting an interactive shell. But I cannot digest what the man page for docker run com...
New
New
AstonJ
I ended up cancelling my Moonlander order as I think it’s just going to be a bit too bulky for me. I think the Planck and the Preonic (o...
New
Margaret
Hello content creators! Happy new year. What tech topics do you think will be the focus of 2021? My vote for one topic is ethics in tech...
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
Help
I am trying to crate a game for the Nintendo switch, I wanted to use Java as I am comfortable with that programming language. Can you use...
New
New
AstonJ
This is a very quick guide, you just need to: Download LM Studio: https://lmstudio.ai/ Click on search Type DeepSeek, then select the o...
New

Latest in PragProg

View all threads ❯