Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow not indenting the test failure message #240

Open
jfmengels opened this issue Jan 12, 2025 · 0 comments
Open

Allow not indenting the test failure message #240

jfmengels opened this issue Jan 12, 2025 · 0 comments

Comments

@jfmengels
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant