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

A public function to modify the failure string of an Expectation #211

Open
Janiczek opened this issue Dec 17, 2022 · 0 comments
Open

A public function to modify the failure string of an Expectation #211

Janiczek opened this issue Dec 17, 2022 · 0 comments

Comments

@Janiczek
Copy link
Collaborator

ArchitectureTest has this helper:

{-| 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

[1,2,3]
|> Expect.equalLists [3,2,1]
|> Expect.mapFailureReason explainInputs
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