-
Notifications
You must be signed in to change notification settings - Fork 16
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
chore: use jest-serializer-ansi-escapes
#161
chore: use jest-serializer-ansi-escapes
#161
Conversation
[MOCK - cursorSavePosition] | ||
[MOCK - cursorLeft] | ||
<dim>›</> <dim>src/</></>fi</><dim>le-2.js</> | ||
<moveCursorToRow6Column14> |
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.
In ansi-escapes
position is zero based, but in vanilla escapes it is 1 base and also row argument goes first. That’s why [MOCK - cursorTo(13, 5)]
becomes <moveCursorToRow6Column14>
@@ -1,34 +1,9 @@ | |||
import { KEYS } from 'jest-watcher'; | |||
import type { Config } from '@jest/types'; | |||
import { jest } from '@jest/globals'; |
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.
Import is not used anymore.
@@ -4,36 +4,11 @@ import { | |||
JestHookEmitter, | |||
UpdateConfigCallback, | |||
} from 'jest-watcher'; | |||
import stripAnsi from 'strip-ansi'; |
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.
The dependency is still used in code. So I left it in package.json
.
…izer-ansi-escapes
@mrazauskas thanks! Could you add support for node 12 in engines? EDIT: never mind, just dropped it |
…izer-ansi-escapes
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.
thanks! way better 👍
Seems there's a v2 (#163), should we update? |
🎉 This PR is included in version 2.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Thanks! I will send a PR for v2 bit later. It had improved serialization of reset sequences. I was sticking with v1 here to keep diffs smaller (; |
Similar to jestjs/jest#12935
jest-serializer-ansi-escapes
is a replacement for Jest’s internalpretty-format/ConvertAnsi
plugin. It serializes cursor control as well as color and style ANSI escapes.Currently in tests of
jest-watch-typeahead
cursor control escapes are snapped by mockingansi-escapes
. This works, but as you can see in the snapshotsjest-serializer-ansi-escapes
plugin is catching few more missing sequences.Other difference – the mocking solution depends on
ansi-escapes
; the plugin is simply serialising vanilla sequences. Hence, using it makes easier to replaceansi-escapes
in the future.