elm-community/elm-test/1.0.1

NOTE: this package is not compatible with Elm 0.19.1

ElmTest

A unit testing framework for Elm.

Tests

type alias Test =
Test

The core unit representing a runnable test, or a group of tests called a suite.

test : String -> Assertion -> Test

A basic function to create a Test. Takes a name and an Assertion.

defaultTest : Assertion -> Test

Create a Test with a default name automatically chosen based on the inputs. For example, defaultTest (assertEqual 5 5) will be named "5 == 5".

equals : a -> a -> Test

Create a Test which asserts equality between two expressions. For example, (7 + 10) equals (1 + 16) will create a Test which tests for equality between the statements (7 + 10) and (1 + 16).

suite : String -> List Test -> Test

Convert a list of Tests to a test suite. Test suites are used to group tests into logical units, simplifying the management and running of many tests. Takes a name and a list of Tests. Since suites are also of type Test, they can contain other suites, allowing for a more complex tree structure.

Assertions

type alias Assertion =
Assertion

The basic unit of testability.

assert : Bool -> Assertion

Basic function to assert that some expression is True

assertEqual : a -> a -> Assertion

Basic function to assert that two expressions are equal in value.

assertNotEqual : a -> a -> Assertion

Basic function to assser that two expressions are not equal.

lazyAssert : (() -> Bool) -> Assertion

A lazy version of assert. Delays execution of the expression until tests are run.

assertionList : List a -> List a -> List Assertion

Given a list of values and another list of expected values, generates a list of assertions that these values are equal.

pass : Assertion

An assertion that always passes. This is useful when you have test results from another library but want to use ElmTest runners.

fail : String -> Assertion

Create an assertion that always fails, for reasons described by the given string.

Run tests in-program

consoleRunner : Test -> String

Run a test or a test suite with laszlopandy/elm-console and return an IO () action which outputs the test results to console.

stringRunner : Test -> String

Run a test or a test suite and return the results as a String. Mostly useful if you want to implement a different type of output for your test results. If you aren't sure whether or not to use this function, you should probably use either elementRunner or consoleRunner.

Run tests as an app

runSuite : Test -> Program Never

run a suite as a program