process.stdout
is undefined in many cases on Windows OS and Vitest uses it in few places
#1292
Closed
6 tasks done
Describe the bug
process.stdout
is often seem to be causing issues on Windows and is often undefined in many cases on Windows OS and Vitest is trying to get TTY width in a few areas by callingprocess.stdout.columns
(and mayberows
too) and this throws an error in Windows. This bug is very similar to another bug #1231 that I opened that got fixed not long ago for the same reason. So as far as I can seeprocess.stdout
really seems to be a problem on Windows.I also found this SO asking similar question:
SO - How can I access stdout.columns in Node on Windows?
and other GitHub projects with similar issue
Facebook Flow - Support for
process.stdout.columns
process.stdout.columns
(androws
) is only available whenprocess.stdout.isTTY
istrue
Searching for
process.stdout
in Vitest code is returning 7 places, 1 of them got fixed on Windows by callingconsole._stdout
as mentioned in #1231 and fixed in #1235. Considering this, would it be possible to find alternative toprocess.stdout
to avoid Vitest itself throwing errors on Windows platform?Reproduction
This simple unit test on Windows will throw a Vitest error coming from
process.stdout.columns
(whereprocess.stdout
is undefined and throws that it cannot read "columns" from undefined)will throw this Vitest error
if I go in Vitest internal code and change
process.stdout.columns
toprocess.stdout && process.stdout.columns
then it works and I see the full errorFor my use case, the error seems to come from
formatLine
vitest/packages/vitest/src/node/diff.ts
Lines 5 to 7 in b027d16
changing it to this line no longer throws from Vitest and allows me to see the real error
Again this is really similar to the error I had reported earlier in #1231
System Info
Used Package Manager
yarn
Validations
The text was updated successfully, but these errors were encountered: