elm-community/elm-test/3.0.0

NOTE: this package is not compatible with Elm 0.19.1

Test.Runner

A collection of functions used by authors of test runners. To run your own tests, you should use these runners; see the README for more information.

Runner

type Runner
= Runnable Runnable
| Labeled String Runner
| Batch (List Runner)

A structured test runner, incorporating:

  • The expectations to run
  • The hierarchy of description strings that describe the results
fromTest : Int -> Seed -> Test -> Runner

Convert a Test into a Runner.

In order to run any fuzz tests that the Test may have, it requires a default run count as well as an initial Random.Pcg.Seed. 100 is a good run count. To obtain a good random seed, pass a random 32-bit integer to Random.Pcg.initialSeed. You can obtain such an integer by running Math.floor(Math.random()*0xFFFFFFFF) in Node. It's typically fine to hard-code this value into your Elm code; it's easy and makes your tests reproducible.

Runnable

An unevaluated test. Run it with run to evaluate it into a list of Expectations.

run : Runnable -> List Expectation

Evaluate a Runnable to get a list of Expectations.

Formatting

formatLabels : (String -> format) -> (String -> format) -> List String -> List format

A standard way to format descriptiona and test labels, to keep things consistent across test runner implementations.

The HTML, Node, String, and Log runners all use this.

What it does:

  • drop any labels that are empty strings

  • format the first label differently from the others

  • reverse the resulting list

    [ "the actual test that failed" , "nested description failure" , "top-level description failure" ] |> formatLabels ((++) "↓ ") ((++) "✗ ")

    {- [ "↓ top-level description failure" , "↓ nested description failure" , "✗ the actual test that failed" ] -}