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

fix: send stderr header log to stderr #2736

Merged
merged 1 commit into from Jan 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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