I am curious if there is some simple way to modify the definition of init to make it possible to test it directly?
init : flags -> Url -> Key -> ( model, Cmd msg )
I am not sure if I even want to be implementing tests at such a high level, but I was just curious.
I’m guessing people will recommend that I define a helper function like:
initHelper : flags -> Url -> (Model a -> Model a) -> ( Model a, Cmd msg)
to abstract references to the Key, if my model stores the Key.
I am also curious to read through full test suites for larger Elm apps.
That library looks nice.
Looks like you need to slightly reorganize your program to use it: elm-program-test/NavigationKeyExample.elm at main · avh4/elm-program-test · GitHub
I might try something simpler that is focused on init only to get going.
As I reflect more on this, if elm/browser chooses to hide the implementation of Key, then elm/browser should also provide some utilities for testing contexts. It feels like a lot of noise to have to define an effect variant for each potential command occurring after init/update.
I also noticed that the elm/browser package does not have a test suite. For a community that uses testability as a selling point, I would generally expect all core libraries have test suites easily browseble on GitHub close to the source code.