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 console in watch mode #1183

Closed
4 tasks done
vdawg-git opened this issue Apr 22, 2022 · 9 comments
Closed
4 tasks done

Clear console in watch mode #1183

vdawg-git opened this issue Apr 22, 2022 · 9 comments
Labels
enhancement New feature or request pr welcome

Comments

@vdawg-git
Copy link

vdawg-git commented Apr 22, 2022

Clear and concise description of the problem

When iterating over components, while having my test run in the background, the console starts to fill up extremely fast and it becomes hard to get to the beginning of the latest report.
If the console would clear itself, simply scrolling up would suffice.
I also had some other ideas, which might be cool.

Suggested solution

Providing an option to toggle this behaviour in the config maybe like this:

// vitest.config.js || vite.config.js . test
  {
        ... ,
        watch: {
            clear:  true,
            reporter: "dot",  // maybe also offering the option to change the reporter for watch mode? 
            stackTrace: false,   // could be useful, when you have a lot of failing test and the stack trace creates a lot of noise
        }

  }

Alternative

Also making some / all functionality part of the interactive CLI.
The "show no stack trace" would fit in quite well there, since hard-coding that in the configuration could be suboptimal, but be just right during one session.
The others maybe not that much.

Additional context

No response

Validations

@underfisk
Copy link

underfisk commented Apr 26, 2022

I've run into this issue before, looking for a solution to prevent the logs of just simply disappearing or when an uncaught error is thrown to be able to read it, this is also replicable on the single run mode
The screenshot below will show also something that happens with the console during development

Screenshot 2022-04-26 at 11 51 54 PM

@antfu antfu added enhancement New feature or request pr welcome labels Aug 29, 2022
@antfu
Copy link
Member

antfu commented Aug 29, 2022

Open for PR, thanks!

@sheremet-va
Copy link
Member

Console is cleared in watch mode by default.

@gkiely
Copy link

gkiely commented May 30, 2023

@sheremet-va While it clears the console it retains the past results and scrollbar so it does not function like ⌘ + k.

This is an issue when debugging something like testing-library that outputs dom html that can take up a lot of vertical screen space. A user would scroll up and then has to scroll back down to re-engage the terminal instead of just updating a test and seeing the new results.

I can provide a video of this if you need to see the issue in detail.

The ability to truly clear the terminal like Jest does would be great.

@sheremet-va
Copy link
Member

@sheremet-va While it clears the console it retains the past results and scrollbar so it does not function like ⌘ + k.

This is an issue when debugging something like testing-library that outputs dom html that can take up a lot of vertical screen space. A user would scroll up and then has to scroll back down to re-engage the terminal instead of just updating a test and seeing the new results.

I can provide a video of this if you need to see the issue in detail.

The ability to truly clear the terminal like Jest does would be great.

Vitest clears the terminal like Jest does. Check that you don't disable clearScreen in your configuration.

@gkiely
Copy link

gkiely commented May 30, 2023

Here's what I mean:
https://www.loom.com/share/4570b607ff564cd4b2dcb0a1947532dd

Jest clears the scrollbar and terminal where vitest does not.

I'm running that without a config, just: vitest --dom --globals

@sheremet-va
Copy link
Member

Here's what I mean: loom.com/share/4570b607ff564cd4b2dcb0a1947532dd

I cannot reproduce it:

Screen.Recording.2023-05-31.at.09.40.46.mov

@gkiely
Copy link

gkiely commented Jun 1, 2023

@sheremet-va Try in the mac terminal.

@AriPerkkio
Copy link
Member

Try in the mac terminal.

I'm able to reproduce this on Mac's terminal. However it works fine using VSCode's internal terminal and Warp.

Here's minimal reproduction case which demonstrates the issue. Run script, manually scroll up and wait for 3s. Mac terminal is the only one that does not work. The logger.clearFullScreen does not work as expected.

// 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(`\x1Bc${message}`); // Vitest's logger.clearFullScreen
console.log("Testing");

Top left terminal is Warp, top right Mac terminal and bottom one is VSCode:

terminals-repro-1.mov

@github-actions github-actions bot locked and limited conversation to collaborators Jun 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request pr welcome
Projects
None yet
Development

No branches or pull requests

6 participants