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 terminal in watch mode #3608

Closed
6 tasks done
gkiely opened this issue Jun 18, 2023 · 3 comments · Fixed by #3661
Closed
6 tasks done

Clear terminal in watch mode #3608

gkiely opened this issue Jun 18, 2023 · 3 comments · Fixed by #3661

Comments

@gkiely
Copy link

gkiely commented Jun 18, 2023

Describe the bug

When using large amounts of text the terminal does not clear on save using macOS.

See #1183 for details.

Reproduction

See instructions from: #1183

System Info

System:
    OS: macOS 12.2.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 244.83 MB / 32.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 20.2.0 - ~/.volta/tools/image/node/20.2.0/bin/node
    Yarn: 1.22.18 - ~/.volta/tools/image/yarn/1.22.18/bin/yarn
    npm: 9.6.6 - ~/.volta/tools/image/node/20.2.0/bin/npm
    Watchman: 2023.04.10.00 - /opt/homebrew/bin/watchman
  Browsers:
    Brave Browser: 112.1.50.119
    Chrome: 114.0.5735.133
    Edge: 114.0.1823.51
    Firefox: 114.0
    Safari: 15.3

Used Package Manager

npm

Validations

@AriPerkkio
Copy link
Member

AriPerkkio commented Jun 19, 2023

@gkiely this happens only on MacOS's built-in Terminal application, right? Any other terminal works fine at least based on my testing at #1183 (comment).

If I add following to the reproduction script, the terminal is cleared correctly:

// repro.mjs
const message = "Hello World";

await new Promise((r) => setTimeout(r, 1000));
Array(200).fill(0).forEach((_, i) => console.log(`Row ${i}`));
console.log("Scroll up now");

await new Promise((r) => setTimeout(r, 3000));
+ console.log('\x1B[2J\x1B[3J\x1B[H');
console.log(`\x1Bc${message}`); // Vitest's logger.clearFullScreen
console.log("Testing");

This is something that could probably be added here:

this.console.log(`\x1Bc${message}`)

+   this.console.log('\x1B[2J\x1B[3J\x1B[H')
    this.console.log(`\x1Bc${message}`)

This seems to work at least on my machine but I'm not really familiar with raw ANSI-codes. I picked the sequence from here: sindresorhus/ansi-escapes#25 (comment).

@gkiely
Copy link
Author

gkiely commented Jun 19, 2023

this happens only on MacOS's built-in Terminal application, right?

Yes

@AriPerkkio
Copy link
Member

Jest clears the scrollbar and terminal where vitest does not.
#1183 (comment)

Jest seems to indeed be using different ANSI codes than Vitest. We should try to change Vitest to use the same \x1B[2J\x1B[3J\x1B[H and do extensive testing with different terminals on different OS's:

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

Successfully merging a pull request may close this issue.

2 participants