-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
when using debug
to print to console, output is missing on reruns
#1768
Comments
I managed to make the logging from |
It may be related to length. By trading streams perhaps it is just giving it a little more time before it fills up again. #2671 (comment) |
Turns out, the issue is to do with the spinner used by the default test reporter. If the default test reporter is changed to 'dot' or any other one that doesn't have a spinner in it, the output is preserved with no issue. |
actually even 'dot' does some clearing of the terminal, so for #2671 when only a single character is being printed to stderr, it is only visible using a reporter than does not change any existing output on the terminal. Currently the 'tap' reporter is working for even a single character output. |
Here's the workaround I'm using. import createDebug from 'debug'
export let debug = createDebug('foo')
if (process.env.TEST && debug.enabled) {
debug = console.log.bind(console) as any
debug.enabled = true
} |
This is because I think this is working intended and it's necessary to override Just one more idea is that it looks like it's possible to overriding the default export directly from setup files. I'll leave a latest repro here https://stackblitz.com/edit/vitest-dev-vitest-mjacyu?file=test%2Fsetup.ts and let me close the issue as it's working intended. import createDebug from 'debug';
createDebug.log = console.error.bind(console);
|
I see couple of issues here:
Using the |
Describe the bug
I am using the
debug
tool with vitest and cannot reliably get output from this tool. It appears as tho when in watch mode, vitest clears the console and wipes anydebug
output under some circumstances.the
debug
library writes to stderr rather than stdout, so perhaps the clearing code in vite should account for lines due to stderr somehow ?Thank you kindly for vitest - it makes life so much better.
Reproduction
https://stackblitz.com/edit/vitest-dev-vitest-qiyvqq?file=test%2Fsuite.test.ts,package.json&initialPath=__vitest__
In terminal, press enter to trigger test reruns and observe the output to console from the debug() library.
Then start editing any file to trigger a test rerun, and observe the output to console from debug() is removed.
System Info
Used Package Manager
yarn
Validations
The text was updated successfully, but these errors were encountered: