majestic icon indicating copy to clipboard operation
majestic copied to clipboard

Feature request: Syntax highlighter for snapshots?

Open lkostrowski opened this issue 5 years ago • 7 comments

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

lkostrowski avatar Mar 30 '19 15:03 lkostrowski

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.

Raathigesh avatar Mar 31 '19 09:03 Raathigesh

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!

lkostrowski avatar Mar 31 '19 11:03 lkostrowski

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

Raathigesh avatar Apr 02 '19 10:04 Raathigesh

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

lkostrowski avatar Apr 02 '19 11:04 lkostrowski

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.

stale[bot] avatar May 02 '19 11:05 stale[bot]

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.

briwa avatar May 05 '19 07:05 briwa

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

Raathigesh avatar May 05 '19 13:05 Raathigesh