-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Adds '--clear-screen' option to clear screen between watch runs #3355
base: main
Are you sure you want to change the base?
Conversation
3f24214
to
4674c0d
Compare
Correction: it works fine using |
I have no opinion whether this should be added, but the flag should be |
I'm not personally a fan of the more verbose I gave this a short alias of |
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.
Yea I don't mind this. Our long-form flags are not abbreviated so 👍 on --clear-screen
.
Do we want to keep this as a CLI flag only or also support it in the configuration?
Testing wise, this could be a permutation of
ava/test-tap/reporters/default.js
Line 45 in 024de32
t.test('default reporter - watch mode run', run('watch')); |
@@ -128,6 +131,10 @@ export default class Reporter { | |||
} | |||
|
|||
startRun(plan) { | |||
if (this.clearScreen) { | |||
this.lineWriter.write(ansiEscapes.clearTerminal); | |||
} |
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.
Maybe move this down into the if (this.watching && !plan.firstRun)
line below? It better connects clearScreen
with watch mode plus maybe there's no need to clean the terminal on the first run? Or does that get weird?
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.
I had it somewhere down there to start, but then it occurred to me that --clear-screen
without --watch
had no effect at all, which simply felt "unhandled". Why not have it clear the screen? 🤔
Since then I've been actually using it without the watch flag just as often as with it.
Thanks for the pointers, I'll try to get those tests updated, and yes having it config makes sense 👍 |
This is very slapped together, but I wanted it for myself and figured I'd start the conversation. If you are even open to mergin it let me know of any changes.
Usage:
What does this PR change?
Between test runs, it sends
this.lineWriter.write(ansiEscapes.clearTerminal)
, which clears the screen and scrollback buffer on all the terminal apps I have handy.I promoted this same behaviour in TypeScript, I guess it's my hill to die on 🤣 (in that case,
--watch
was already clearing the screen, this just changed/improved the behaviour).Jest also clears the screen when using
--watch
. I prefer it, FWIW, but I've read the argument for keeping all those logs... I'm not convinced, but hey that's just me. I'd be happy w/--clear-screen
though it isn't exactly very discoverable atm.WDYT?