Learn how to test your Elm exercises on Exercism
Tests for an Elm project live in the tests/
subdirectory of that project.
Each exercise tests suite can be run from that exercise root directory.
$ cd ~/exercism/elm/hello-world
$ elm-test
Automatically run tests again when you save changes:
$ elm-test --watch
In most exercises, tests are already written in the file tests/Tests.elm
.
Your goal is to make them pass by writing the code required
in the src/<exercise>.elm
file.
Focus on the first failing test, fix it,
then remove or comment the next skip <|
snippet in the tests file and repeat
until all tests pass.
Your first goal is to get your code to compile, even with Debug.todo
in it.
If you feel you don't know how to do something,
it is often useful to extract that piece into its own unimplemented function.
complexOperationOnMultipleStrings : List String -> List String
complexOperationOnMultipleStrings allStrings =
List.map complexOperation allStrings
complexOperation : String -> String
complexOperation input =
Debug.todo "Extracted operation into its own function"
Adding a type annotation on this extracted function will both help your thinking and the compiler to give you better error messages.
Consider running elm-format
on your code before submitting it
and even setting it up in your text editor for automatic formatting on save.