Skip to content

Commit

Permalink
fix: clear terminal output before running tests, show errors in corre…
Browse files Browse the repository at this point in the history
…ct order (#2228)
  • Loading branch information
sheremet-va committed Oct 31, 2022
1 parent 0be5024 commit a1ee96a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
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

0 comments on commit a1ee96a

Please sign in to comment.