Skip to content
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

Clear scrollback on terminal clear in watch mode #2230

Merged
merged 3 commits into from
Dec 8, 2016

Conversation

ColCh
Copy link
Contributor

@ColCh ColCh commented Dec 6, 2016

simply tweak clear codes and check 'em in different envs
main purpose was to clear scrollback buffer, instead of just clearing screen

Summary

clear scroll back on watch mode. helps a lot if you have output which you want to scroll up

Test plan

tested with this diff just to show that I have patched version of jest running:

diff --git a/packages/jest-cli/src/jest.js b/packages/jest-cli/src/jest.js
index f499dd3..77ff3e1 100644
--- a/packages/jest-cli/src/jest.js
+++ b/packages/jest-cli/src/jest.js
@@ -285,6 +285,7 @@ const runCLI = (
   argv = argv || {};
   if (argv.version) {
     pipe.write(`v${VERSION}\n`);
+    pipe.write(`PATCHED VERSION FROM 1861-clr-scroll-on-watch\n`);
     onComplete && onComplete();
     return;
   }

on each test, I have to add jest/packages to NODE_PATH and do npm link inside of jest/packages/jest-cli, to make patched jest available globally

then run jest --version just to ensure that I'm running my patched version, and then, finally, run jest --watch

checked on:

  • OS X with zsh
  • Windows 7 with cmd
  • Ubuntu with bash

(sorry, no videos nor gifs. removed them)

I think I have not break anything with this change. However, windows 10 with powershell is untested. Do you want me to test it also, @cpojer ?

And, cc @gaearon , please take a look on this PR.

P.S. However, I don't have GUI Linux and can't check on it...

@ColCh ColCh changed the title [HEAVY GIFS INSIDE] Clear scrollback on terminal clear in watch mode Clear scrollback on terminal clear in watch mode Dec 6, 2016
@ColCh
Copy link
Contributor Author

ColCh commented Dec 6, 2016

And, yup, this PR is related and should close #1861

@codecov-io
Copy link

codecov-io commented Dec 6, 2016

Current coverage is 89.36% (diff: 100%)

Merging #2230 into master will not change coverage

@@             master      #2230   diff @@
==========================================
  Files            39         39          
  Lines          1467       1467          
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
  Hits           1311       1311          
  Misses          156        156          
  Partials          0          0          

Powered by Codecov. Last update 88cdb51...a7a51d8

@gaearon
Copy link
Contributor

gaearon commented Dec 7, 2016

I'll take a look at this next week. I want to test it thoroughly but my schedule is just too packed right now and I need more time.

@SimenB
Copy link
Member

SimenB commented Dec 8, 2016

Will this work correctly in a tmux pane as well?

@ColCh
Copy link
Contributor Author

ColCh commented Dec 8, 2016

@SimenB yes. from 1.6 version

link to tmux changes file:
https://github.com/tmux/tmux/blob/23254f59daea7415c96bc323d3b48d35c1b21327/CHANGES#L391-L392

Support for \e[3J to clear the history and send the corresponding
terminfo code (E3) before locking.

@SimenB
Copy link
Member

SimenB commented Dec 8, 2016

Awesome, thanks for digging that up!

@gaearon
Copy link
Contributor

gaearon commented Dec 8, 2016

LGTM.

@cpojer cpojer merged commit 56a39af into jestjs:master Dec 8, 2016
skovhus pushed a commit to skovhus/jest that referenced this pull request Apr 29, 2017
* Send reset screen symbol instead of clear

* Use other symbol for clearing terminal on Windows

* Clear remaining screen on linux/os x
tushardhole pushed a commit to tushardhole/jest that referenced this pull request Aug 21, 2017
* Send reset screen symbol instead of clear

* Use other symbol for clearing terminal on Windows

* Clear remaining screen on linux/os x
@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants