test(logger): use jest-serializer-ansi-escapes#7685
Merged
Josh-Cena merged 2 commits intoJun 27, 2022
Conversation
mrazauskas
commented
Jun 26, 2022
| import ansiEscapesSerializer from 'jest-serializer-ansi-escapes'; | ||
| import logger from '../index'; | ||
|
|
||
| // cSpell:ignore mkeep |
Contributor
Author
There was a problem hiding this comment.
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
|
Josh-Cena
requested changes
Jun 26, 2022
Contributor
Author
|
@Josh-Cena Thanks for review. Just moved the serialiser to |
Collaborator
|
Oh, I suddenly realize we already have this: #7131 Yeah I think this is fair enough. Thanks! |
Josh-Cena
approved these changes
Jun 26, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Pre-flight checklist
Motivation
I noticed that ansi escape sequences are included in snapshots of
@docusaurus/loggertests. 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-escapesis inspired byConvertAnsiplugin which ships withpretty-formatand is bundled with Jest as well. CurrentlyConvertAnsidoes not supportblueorunderline. 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 likechalkand 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