elm-explorations / elm-explorations/test

A public function to modify the failure string of an Expectation

Open
#211 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Elm
Stars
244
Forks
40
Avg merge
1d 23h
Merged PRs (30d)
2

Description

ArchitectureTest has this helper:
```elm
{-| A nice custom failure message for a failing expectation.

Now if only there was a way to get rid of the "Given ..." :)

-}
customFailure : Expectation -> (String -> String) -> Expectation
customFailure expectation failureString =
case Test.Runner.getFailureReason expectation of
Nothing ->
Expect.pass

Just { description, reason } ->
Test.Runner.Failure.Extra.format description reason
|> failureString
|> Expect.fail
```
to use the nicely-formatted failure string, but wrap it in some explanations of its own.

This helper might be useful to others as well? Maybe it could live in this library, perhaps as `mapFailureReason` or something similar

```elm
[1,2,3]
|> Expect.equalLists [3,2,1]
|> Expect.mapFailureReason explainInputs
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.