testify
testify copied to clipboard
Colorize "expected" and "actual"
Can we have an option to colorize "expected" and "actual" in test output? Like this:
For me the colors helps because it allows me to locate the diff faster. This kind of coloring is very common in Node.js test frameworks.
It's an interesting idea. I'm slightly leaning towards keeping testify as simple as possible but ultimately we do it for the community. If there is strong support for this, I'd be happy to look into it :)
I like this idea. Perhaps the default should be set to the current behaviour and starting 2.0 we could enable it by default?
@boyan-soubachov I'd say let's do this assuming we can keep it a lightweight and KISSy solution.
Anyone any concrete ideas for a PR?
I recommend an interface for decorating the output. The default implementation behaves as is now without decorating the output. Then anyone could implement this interface for colourful output.
Example
Spec library has this interface for generating reports. Here is an example implementation.
Agreed with @arsham. I think it makes a lot more sense to provide the interface which users can customize. Not all users can see specific colours the same or well, not all colours have the same meanings to all people, etc.
So, since we're agreed that this is a nice idea... Here's an initial spec sheet for this new feature:
- [ ] Use an interface for decoration
- [ ] Default interface implementation should leave the output undecorated (pre 2.0 at least)
- [ ] An optional implementation should be provided for people who just want it to work
- [ ] Initial optional implementation should colourize actual vs expected at the very least
For now I don't think it should be more than this.
This will detect when running in interactive vs non-iterative mode (i.e. I don't want to see control characters in logged output).
Are there plans to merge https://github.com/stretchr/testify/pull/1232?
Just here to say that I would also love a little bit of colour! It makes it a little bit easier for people's eyes to parse the information dump that they see on the screen. Seems like a good addition to the suite :+1: