Skip to content

ktonon/elm-test-extra

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

elm-test-extra

elm-package CircleCI

Extra expectations, fuzzers, testers and describers.

elm package install ktonon/elm-test-extra

Example: Describing JSON Decoders

Write concise test for JSON decoders.

Use the high level describeDecoder to quickly write tests that exercise a Json.Decode.Decoder. For example,

describeDecoder "int"
  Json.Decode.int
  Debug.toString
  [ ( "", FailsToDecode )
  , ( "\"foo\"", FailsToDecode )
  , ( "1", DecodesTo 1 )
  , ( "1.5", FailsToDecode )
  , ( "\"this-will-fail\"", DecodesTo 5)
  ]

In this example, the last test will fail, giving helpful feedback:

↓ int
✗ this-will-fail DecodesTo 5

Expected input:
  "this-will-fail"
to decode successfully, but instead it failed with message:
  Problem with the given value:

"this-will-fail"

Expecting an INT

About

Write concise tests for JSON decoders and more

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages