Great compiler messages? Great test failure messages!

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


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.


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.