-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
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
test(logger): use jest-serializer-ansi-escapes
#7685
test(logger): use jest-serializer-ansi-escapes
#7685
Conversation
import logger from '../index'; | ||
|
||
// cSpell:ignore mkeep |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By the way, snapshots become cSpell
friendly as well.
✅ [V2]Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site settings. |
⚡️ Lighthouse report for the deploy preview of this PR
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Josh-Cena Thanks for review. Just moved the serialiser to |
Oh, I suddenly realize we already have this: #7131 Yeah I think this is fair enough. Thanks! |
Pre-flight checklist
Motivation
I noticed that ansi escape sequences are included in snapshots of
@docusaurus/logger
tests. Recently I wrote a snapshot serializer which is replacing the sequences with human readable strings. For example,'\u001b[3;32mSuccess!\u001b[0m'
gets snapshotted as'<italic, green>Success!</>'
.Just though – perhaps you will find it useful? After using the plugin in a couple of projects, it felt to me that the improved readability helps to maintain snapshots. Of course, in the end the same output is snapshotted.
jest-serializer-ansi-escapes
is inspired byConvertAnsi
plugin which ships withpretty-format
and is bundled with Jest as well. CurrentlyConvertAnsi
does not supportblue
orunderline
. Also its implementation is based onansi-styles
(which does not work for vanilla sequences with more than one arguments:\u001b[3;32m
).These and similar limitations was the reason why I created
jest-serializer-ansi-escapes
. It supports vanilla escape sequences as well as the ones produced by libraries likechalk
and it replaces color, style and cursor control escape sequences.Test Plan
Snapshots are updated. All current tests should pass.
Test links
N/A
Related issues/PRs
N/A