Raathigesh / majestic

⚡ Zero config GUI for Jest
MIT License
7.5k stars 174 forks source link

Feature request: Syntax highlighter for snapshots? #92

Open lkostrowski opened 5 years ago

lkostrowski commented 5 years ago

Feature request: Syntax highlighter for snapshots?

Hi

Do you think it's possible to make snapshots display highlighted? It could be much more readble during comparison

Raathigesh commented 5 years ago

The syntax is highlighted by default by passing --colors flag to Jest and then converting the output through https://www.npmjs.com/package/ansi-to-html but I have seen some instances where they are not highlighted.

Could you please let me know which version of Jest you are using and also would you be able to share a screenshot?

If you share a sample repo with highlight not working, it would be really useful as well.

lkostrowski commented 5 years ago

Hmmm not sure if we are on the same page, let me clarify

I am using create-react-app with typescript. It currently is 23.6.0 but it doesn't matter. When I run default test run, it is colored, but not syntax highligted, and AFAIK this is what --colors stands for (red / green diffs).

Screen:

Image 2019-03-31 at 1 35 25 PM

In case of Majestic, it's not hightlighted

Image 2019-03-31 at 1 37 48 PM

But export FORCE_COLOR=true or passing color arg does the same, so thats perfectly fine.

What I'm thinking is some smart solution to detect HTML and highlight it. ansi-to-html might be good to try writing some jest plugin, but I don't test only only html - snapshots are also great to test some mappings which output json-like format

Anyway - not a bug!

Raathigesh commented 5 years ago

At least we could highlight based on the + and -.

lkostrowski commented 5 years ago

Yes, since colors is default in Jest, I think it should be default in Majestic config too. Actually IMO all default configs from jest should be passed

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

briwa commented 5 years ago

Is it just me or this has been fixed at least in master? Screen Shot 2019-05-05 at 3 51 36 PM

Seems like the colors are all ok on my side.

Raathigesh commented 5 years ago

I guess sometimes Jest doesn't send colors properly, unfortunately.