Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ktonon/elm-test-extra
Write concise tests for JSON decoders and more
https://github.com/ktonon/elm-test-extra
elm elm-test
Last synced: 2 months ago
JSON representation
Write concise tests for JSON decoders and more
- Host: GitHub
- URL: https://github.com/ktonon/elm-test-extra
- Owner: ktonon
- License: mit
- Created: 2017-01-18T01:23:54.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2020-07-03T21:38:03.000Z (over 4 years ago)
- Last Synced: 2024-09-29T08:05:18.422Z (3 months ago)
- Topics: elm, elm-test
- Language: Elm
- Homepage:
- Size: 25.4 KB
- Stars: 4
- Watchers: 2
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
elm-test-extra
==============[![elm-package](https://img.shields.io/badge/elm-2.0.1-blue.svg)](http://package.elm-lang.org/packages/ktonon/elm-test-extra/latest)
[![CircleCI](https://img.shields.io/circleci/project/github/ktonon/elm-test-extra.svg)](https://circleci.com/gh/ktonon/elm-test-extra)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,
```elm
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 5Expected input:
"this-will-fail"
to decode successfully, but instead it failed with message:
Problem with the given value:"this-will-fail"
Expecting an INT
```[ktonon/elm-test-extra]:http://package.elm-lang.org/packages/ktonon/elm-test-extra/latest