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

Colorize "expected" and "actual" #946

Open
golopot opened this issue May 13, 2020 · 8 comments · May be fixed by #994, #1232 or #1467
Open

Colorize "expected" and "actual" #946

golopot opened this issue May 13, 2020 · 8 comments · May be fixed by #994, #1232 or #1467

Comments

@golopot
Copy link

golopot commented May 13, 2020

Can we have an option to colorize "expected" and "actual" in test output? Like this:
Screenshot from 2020-05-13 18-27-59

0_ZTerrO_akuDWSV8h

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.

@boyan-soubachov
Copy link
Collaborator

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 :)

@mvdkleijn
Copy link
Contributor

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?

@arsham
Copy link

arsham commented Jul 31, 2020

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.

@boyan-soubachov
Copy link
Collaborator

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.

@mvdkleijn
Copy link
Contributor

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.

@hcmlinj hcmlinj linked a pull request Aug 20, 2020 that will close this issue
@alxn
Copy link
Contributor

alxn commented Jan 16, 2021

This will detect when running in interactive vs non-iterative mode (i.e. I don't want to see control characters in logged output).

@juanzolotoochin
Copy link

Are there plans to merge #1232?

@hugoleborso hugoleborso linked a pull request Sep 6, 2023 that will close this issue
@dolmen dolmen added the enhancement: colored output About adding colored output label Oct 10, 2023
@DennisTheMenace780
Copy link

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 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment