brian-watkins/elm-spec/1.1.0

NOTE: the latest version is 3.3.2

Spec.Runner

Use these functions and types to create the program that will run the spec suite.

Create a Spec Suite Program

type alias Config msg =
{ send : Message -> Cmd (Msg msg)
, outlet : Message -> Cmd msg
, listen : (Message -> Msg msg) -> Sub (Msg msg)
}

The spec suite runner must provide a Config, which must be implemented as follows:

Create two ports:

port elmSpecOut : Message -> Cmd msg
port elmSpecIn : (Message -> msg) -> Sub msg

And then create a Config like so:

config : Spec.Runner.Config msg
config =
  { send = elmSpecOut
  , outlet = elmSpecOut
  , listen = elmSpecIn
  }

The send and outlet attributes must reference the same port, elmSpecOut.

Config msg
-> List (Spec model msg)
-> Program Flags (Model model msg) (Msg msg)

Create a spec suite program for describing the behavior of browser-based programs.

Once you've created the Config value in your Runner module, I suggest adding a function like so:

program : List (Spec model msg) -> Program Flags (Model model msg) (Msg msg)
program =
  Spec.Runner.browserProgram config

Then, each of your spec modules can implement their own main function:

main =
  Runner.program
    [ ... some specs ...
    ]

The JavaScript runner will find each spec module and run it as its own program.

Config msg
-> List (Spec model msg)
-> Program Flags (Model model msg) (Msg msg)

Create a spec suite program for describing the behavior of headless programs.

Once you've created the Config value in your Runner module, I suggest adding a function like so:

program : List (Spec model msg) -> Program Flags (Model model msg) (Msg msg)
program =
  Spec.Runner.program config

Then, each of your spec modules can implement their own main function:

main =
  Runner.program
    [ ... some specs ...
    ]

The JavaScript runner will find each spec module and run it as its own program.

Spec Suite Program Types

type alias Message =
Message

Represents a message to pass between elm-spec and the JavaScript elm-spec runner.

type alias Flags =
Flags

Flags that the JavaScript runner will pass to the spec suite program.

type alias Msg msg =
Msg msg

Used by the spec suite program.

type alias Model model msg =
Model model msg

Used by the spec suite program.