rogeriochaves/elm-test-bdd-style/1.0.0

NOTE: this package is not compatible with Elm 0.19.1

elm-test-bdd-style Build Status

BDD style matchers on top of elm-test

Getting started

First, follow the getting started steps from the elm-test package.

Then, install elm-test-bdd-style:

elm package install rogeriochaves/elm-test-bdd-style

To use it, just import it on your test:

import ElmTestBDDStyle exposing (..)

Usage example

-- Example.elm
module Example where

import ElmTestBDDStyle exposing (..)

tests : Test
tests =
  describe "Example Text"
    [ it "does math correctly" <|
        expect (1 + 1) toBe 2

    , it "does not miscalculate things" <|
        expect (2 + 2) notToBe 5

    , it "exemplifies more complex test cases" <|
        let
          expression = 2 + 2
        in
          expect expression toBe 4
    ]

Right now, elm-test-bdd-style comes only with toBe and notToBe, but it is very easy to create your own matchers:

toBeGreaterThan : comparable -> comparable -> Bool
toBeGreaterThan = (>)

tests : Test
tests =
  describe "Custom matchers"
    [ it "compares two numbers" <|
        expect 10 toBeGreaterThan 5
    ]