Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix: send stderr header log to stderr (#2736)
  • Loading branch information
sheremet-va committed Jan 23, 2023
1 parent 84df112 commit 998ea80
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
4 changes: 2 additions & 2 deletions packages/vitest/src/node/reporters/base.ts
Expand Up @@ -174,8 +174,8 @@ export abstract class BaseReporter implements Reporter {
if (!this.shouldLog(log))
return
const task = log.taskId ? this.ctx.state.idMap.get(log.taskId) : undefined
this.ctx.logger.log(c.gray(log.type + c.dim(` | ${task ? getFullName(task, c.dim(' > ')) : 'unknown test'}`)))
process[log.type].write(`${log.content}\n`)
const header = c.gray(log.type + c.dim(` | ${task ? getFullName(task, c.dim(' > ')) : 'unknown test'}`))
process[log.type].write(`${header}\n${log.content}\n`)
}

shouldLog(log: UserConsoleLog) {
Expand Down
8 changes: 2 additions & 6 deletions packages/vitest/src/runtime/setup.node.ts
Expand Up @@ -76,12 +76,10 @@ export async function setupConsoleLogSpy() {
if (!buffer)
return
const content = buffer.map(i => String(i)).join('')
if (!content.trim())
return
const timer = timers.get(taskId)!
rpc().onUserConsoleLog({
type: 'stdout',
content,
content: content || '<empty line>',
taskId,
time: timer.stdoutTime || RealDate.now(),
size: buffer.length,
Expand All @@ -94,12 +92,10 @@ export async function setupConsoleLogSpy() {
if (!buffer)
return
const content = buffer.map(i => String(i)).join('')
if (!content.trim())
return
const timer = timers.get(taskId)!
rpc().onUserConsoleLog({
type: 'stderr',
content,
content: content || '<empty line>',
taskId,
time: timer.stderrTime || RealDate.now(),
size: buffer.length,
Expand Down

0 comments on commit 998ea80

Please sign in to comment.