Skip to content

Commit 998ea80

Browse files
authoredJan 23, 2023
fix: send stderr header log to stderr (#2736)
1 parent 84df112 commit 998ea80

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed
 

‎packages/vitest/src/node/reporters/base.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,8 @@ export abstract class BaseReporter implements Reporter {
174174
if (!this.shouldLog(log))
175175
return
176176
const task = log.taskId ? this.ctx.state.idMap.get(log.taskId) : undefined
177-
this.ctx.logger.log(c.gray(log.type + c.dim(` | ${task ? getFullName(task, c.dim(' > ')) : 'unknown test'}`)))
178-
process[log.type].write(`${log.content}\n`)
177+
const header = c.gray(log.type + c.dim(` | ${task ? getFullName(task, c.dim(' > ')) : 'unknown test'}`))
178+
process[log.type].write(`${header}\n${log.content}\n`)
179179
}
180180

181181
shouldLog(log: UserConsoleLog) {

‎packages/vitest/src/runtime/setup.node.ts

+2-6
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,10 @@ export async function setupConsoleLogSpy() {
7676
if (!buffer)
7777
return
7878
const content = buffer.map(i => String(i)).join('')
79-
if (!content.trim())
80-
return
8179
const timer = timers.get(taskId)!
8280
rpc().onUserConsoleLog({
8381
type: 'stdout',
84-
content,
82+
content: content || '<empty line>',
8583
taskId,
8684
time: timer.stdoutTime || RealDate.now(),
8785
size: buffer.length,
@@ -94,12 +92,10 @@ export async function setupConsoleLogSpy() {
9492
if (!buffer)
9593
return
9694
const content = buffer.map(i => String(i)).join('')
97-
if (!content.trim())
98-
return
9995
const timer = timers.get(taskId)!
10096
rpc().onUserConsoleLog({
10197
type: 'stderr',
102-
content,
98+
content: content || '<empty line>',
10399
taskId,
104100
time: timer.stderrTime || RealDate.now(),
105101
size: buffer.length,

0 commit comments

Comments
 (0)
Please sign in to comment.