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: clear terminal output before running tests, show errors in correct order #2228

Merged
merged 1 commit into from Oct 31, 2022
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
7 changes: 7 additions & 0 deletions packages/vitest/src/node/cli-wrapper.ts
Expand Up @@ -61,6 +61,13 @@ async function main() {
}
}

// if not specified, don't run through spawn,
// because it prints stderr messages in the wrong order compared to stdout
if (retries <= 0) {
await import('./cli')
return
}

const nodeArgs: string[] = []
const vitestArgs: string[] = []

Expand Down
8 changes: 3 additions & 5 deletions packages/vitest/src/node/logger.ts
Expand Up @@ -47,14 +47,12 @@ export class Logger {
}

private _clearScreen() {
if (!this._clearScreenPending)
if (this._clearScreenPending == null)
return

const log = this._clearScreenPending
this._clearScreenPending = undefined
// equivalent to ansi-escapes:
// stdout.write(ansiEscapes.cursorTo(0, 0) + ansiEscapes.eraseDown + log)
this.console.log(`\u001B[1;1H\u001B[J${log}`)
this.console.log(`\x1Bc${log}`)
}

printError(err: unknown, fullStack = false, type?: string) {
Expand Down Expand Up @@ -84,7 +82,7 @@ export class Logger {
}

printBanner() {
this.log()
this.clearScreen('', true)

const versionTest = this.ctx.config.watch
? c.blue(`v${version}`)
Expand Down