Skip to content

Allow not indenting the test failure message #240

@jfmengels

Description

@jfmengels

In elm-review's testing library, I try to print out helpful failure messages when a test fails. Sometimes that includes code extracts.

    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 #239).

Here's an example of a potential API :

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), so it might be necessary to modify the CLI as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions