# Great compiler messages? Great test failure messages!

**URL:** <https://discourse.elm-lang.org/t/great-compiler-messages-great-test-failure-messages/6936>\
**Category:** Show and Tell\
**Created:** [February 18, 2021, 12:16pm UTC](https://discourse.elm-lang.org/t/great-compiler-messages-great-test-failure-messages/6936 "2021-02-18T12:16:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jfmengels](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/jfmengels/32/3124_2.png) [@jfmengels](https://discourse.elm-lang.org/u/jfmengels)\
**Post date:** [February 18, 2021, 12:16pm UTC](https://discourse.elm-lang.org/t/great-compiler-messages-great-test-failure-messages/6936/1 "2021-02-18T12:16:57Z")

</div>

I wrote a blog post on how to make great test failure messages for `elm-test`. I hope you find it interesting and useful 🙂

> **[Great compiler messages? Great test failure messages!](https://jfmengels.net/great-failure-messages/)**
>
> If you’ve written a little bit of Elm code, I hope you’ve tried out which allows you to write and run tests for your Elm code (if you never heard of it, we…

---

<div class="post-metadata">

**Author:** ![dillonkearns](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/dillonkearns/32/1587_2.png) [@dillonkearns](https://discourse.elm-lang.org/u/dillonkearns)\
**Post date:** [February 18, 2021, 3:26pm UTC](https://discourse.elm-lang.org/t/great-compiler-messages-great-test-failure-messages/6936/2 "2021-02-18T15:26:59Z")

</div>

Very helpful post! I like the tip about using ANSI color codes in error messages, too, I hadn’t considered that. Great stuff!

Another trick that I find helpful is that the Red step in Test-Driven Development is to get the specific error message you want to see. If you see Red, but it’s

- Not Red for the reason you intended, or
- Not Red with a useful error message that tells you how to fix it

Then you’re not done with the red step yet. That little habit helps out a lot, because otherwise it’s easy to move on and end up with unhelpful error messages that get buried in the Green state.

---

<div class="post-metadata">

**Author:** ![lydell](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/lydell/32/178_2.png) [@lydell](https://discourse.elm-lang.org/u/lydell)\
**Post date:** [February 18, 2021, 6:03pm UTC](https://discourse.elm-lang.org/t/great-compiler-messages-great-test-failure-messages/6936/3 "2021-02-18T18:03:17Z")

</div>

One thing to note about the ANSI color codes is that they’ll be in effect even if the user runs `elm-test --no-color`, and they’ll show up as “garbage” for `elm-test --report json` or `elm-test --report junit`. `elm-test` _could_ strip the ANSI codes in those cases, I guess, but currently it doesn’t.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/elm_lang/original/1X/50a05e53677a2c3b47776d7abd0f113eb50193a1.png) [@system](https://discourse.elm-lang.org/u/system)\
**Post date:** [February 28, 2021, 6:04pm UTC](https://discourse.elm-lang.org/t/great-compiler-messages-great-test-failure-messages/6936/4 "2021-02-28T18:04:01Z")

</div>

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.
