elm-explorations / elm-explorations/test
Allow not indenting the test failure message
- Dominant language
- Elm
- Stars
- 244
- Forks
- 40
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 2
Description
In `elm-review`'s testing library, I try to print out helpful failure messages when a test fails. Sometimes that includes code extracts.
```elm
FIXED CODE MISMATCH
I found a different fixed source code than expected for the error with the
following message:
`Let value was declared prematurely`
I expected the following result after the fixes have been applied:
"""
module A exposing (..)
a b c d =
let
y = 1
in
if DIFFERENT then
let
z = {a = 1}
in
{z | a = 2}
else
{a = 3}
"""
but I found:
"""
module A exposing (..)
a b c d =
let
y = 1
in
if b then
let
z = {a = 1}
in
{z | a = 2}
else
{a = 3}
"""
```
I would love to be able to have users (including myself) copy-paste the code excerpts from the failure message, unfortunately, they are indented. Half because of me (to separate from the rest, but I could remove this), but mostly because `elm-test` indents all failure messages by 4 spaces anyway.
I would like to be able to have the option to disable the indentation, possibly by specifying it as an argument on `Expect.onFail` (and eventual friends from https://github.com/elm-explorations/test/issues/239).
Here's an example of a potential API :
```elm
some operation
|> Expect.equal x
|> Expect.onFail { indent = False } "Some explanation..."
```
Note: From a rough search, I think the indentation happens in the CLI ([here](https://github.com/rtfeldman/node-test-runner/blob/master/elm/src/Test/Reporter/Console.elm#L97)), so it might be necessary to modify the CLI as well.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.