chore: replace pretty-format/ConvertAnsi
with jest-serializer-ansi-escapes
#12935
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.
Summary
For one project I needed to have snapshots with ANSI colors.
pretty-format/ConvertAnsi
serialiser was not working in this case, because it is only replacing ANSI escapes originating fromansi-styles
(also used bychalk
). In other words, in the project I have sequences like'\u001b[1;31mSample text'
(bold and red), but in similar caseansi-styles
would emit\u001b[1m\u001b[31mSample text
.After writing a serialiser for vanilla ANSI escapes, I wanted to tryout out on Jest repo. It did not work with cursor control sequences. Oh.. That’s niche case, but interesting one! So the serialiser is now replacing cursor controls as well:
<eraseLine>
,<moveCursorToColumn1>
, etc. See the snapshots for more.This is how
jest-serializer-ansi-escapes
was born. Looks useful. Opening a PR to hear some feedback (;Test plan
Green CI.