This is an alternative site for discovering Elm packages. You may be looking for the official Elm package site instead.
A library for fuzz testing TEA models by simulating user interactions
version 1.0.10
license BSD-3-Clause
native-modules False
elm-version 0.18.0 <= v < 0.19.0
Tag 1.0.10
Committed At 2018-03-24 23:24:07 UTC
elm-lang/html 2.0.0 <= v < 3.0.0 2.0.0
elm-lang/core 5.1.1 <= v < 6.0.0 5.1.1
elm-community/elm-test 4.1.0 <= v < 5.0.0 4.2.0

README

ArchitectureTest

tl;dr: Fuzz-test your update function with random List Msgs!

(Click on the diagram below for full size!)

High-level diagram

To do this, you create a Msg fuzzer (and possibly a Model fuzzer) and plug it in test functions exposed here!

  • Here are example Models with test suites showing how to write these kinds of tests.
  • Richard Feldman has a simpler library rtfeldman/test-update with the same purpose - give it a look!
  • A talk about this topic will be presented at Elm Europe 2017.
  • For more discussion, see this issue of elm-test.

FAQ

Can Elm enumerate over your Msg type automatically?

No, it cannot (as of version 0.18). You will have to specify your Msg fuzzers by hand:

cancel : Fuzzer Msg
cancel =
    Fuzz.constant Cancel

addCoins : Fuzzer Msg
addCoins =
    Fuzz.intRange 0 Random.maxInt
        |> Fuzz.map AddCoins

-- some other Msg fuzzers... and then, combine them:

allMsgs : Fuzzer Msg
allMsgs =
    Fuzz.oneOf
        [ cancel
        , addCoins
        , buy
        , takeProduct
        ]

How can I focus my Msgs (prefer some of them more than others?)

Right, so Fuzz.oneOf gives all the options the same probability of being chosen. It internally uses Fuzz.frequency, which you can use too and specify your own probabilities!

preferAdding : Fuzzer Msg
preferAdding =
    Fuzz.frequency
        [ (1, cancel)
        , (10, addCoins)
        , (1, buy)
        , (1, takeProduct)
        ]