Skip to content

Commit

Permalink
fix: tap reporter doesn't throw
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Aug 6, 2022
1 parent 18e0bec commit 09551e2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/vitest/src/node/logger.ts
Expand Up @@ -108,7 +108,7 @@ export class Logger {
async printUnhandledErrors(errors: unknown[]) {
const errorMessage = c.red(c.bold(
`\nVitest caught ${errors.length} unhandled error${errors.length > 1 ? 's' : ''} during the test run. This might cause false positive tests.`
+ '\nPlease, resolve all the errors to make sure your tests are not affected.',
+ '\nPlease, resolve all errors to make sure your tests are not affected.',
))
this.log(c.red(divider(c.bold(c.inverse(' Unhandled Errors ')))))
this.log(errorMessage)
Expand Down
11 changes: 5 additions & 6 deletions packages/vitest/src/node/reporters/renderers/indented-logger.ts
@@ -1,8 +1,7 @@
export class IndentedLogger<T = any> {
private currentIndent = ''
import { Logger } from '../../logger'

constructor(private baseLog: (text: string) => T) {
}
export class IndentedLogger extends Logger {
private currentIndent = ''

indent() {
this.currentIndent += ' '
Expand All @@ -12,7 +11,7 @@ export class IndentedLogger<T = any> {
this.currentIndent = this.currentIndent.substring(0, this.currentIndent.length - 4)
}

log(text: string): T {
return this.baseLog(this.currentIndent + text)
log(text: string) {
return super.log(this.currentIndent + text)
}
}
2 changes: 1 addition & 1 deletion packages/vitest/src/node/reporters/tap.ts
Expand Up @@ -20,7 +20,7 @@ export class TapReporter implements Reporter {

onInit(ctx: Vitest): void {
this.ctx = ctx
this.logger = new IndentedLogger(this.ctx.logger.log.bind(this.ctx))
this.logger = new IndentedLogger(ctx)
}

static getComment(task: Task): string {
Expand Down

0 comments on commit 09551e2

Please sign in to comment.