feat: show file name in suite error

This commit is contained in:
Anthony Fu 2021-12-23 16:38:09 +08:00
parent 606ec9c50e
commit faae94de72
3 changed files with 5 additions and 2 deletions

View File

@ -59,6 +59,7 @@ declare global {
const readonly: typeof import('vue')['readonly']
const ref: typeof import('vue')['ref']
const refDefault: typeof import('@vueuse/core')['refDefault']
const resolveComponent: typeof import('vue')['resolveComponent']
const shallowReactive: typeof import('vue')['shallowReactive']
const shallowReadonly: typeof import('vue')['shallowReadonly']
const shallowRef: typeof import('vue')['shallowRef']

View File

@ -1,7 +1,7 @@
import { performance } from 'perf_hooks'
import { relative } from 'pathe'
import c from 'picocolors'
import type { Reporter, TaskResultPack, UserConsoleLog } from '../types'
import type { File, Reporter, TaskResultPack, UserConsoleLog } from '../types'
import { getSuites, getTests } from '../utils'
import type { Vitest } from '../node'
import { printError } from './diff'
@ -70,7 +70,8 @@ export class ConsoleReporter implements Reporter {
this.ctx.error(c.red(divider(c.bold(c.inverse(` Failed Suites ${failedSuites.length} `)))))
this.ctx.error()
for (const suite of failedSuites) {
this.ctx.error(c.red(`\n- ${getFullName(suite)}`))
const filepath = (suite as File)?.filepath || ''
this.ctx.error(c.red(`\n- ${getFullName(suite)} ${c.dim(`[ ${this.relative(filepath)} ]`)}`))
await printError(suite.result?.error, this.ctx)
errorDivider()
}

View File

@ -33,6 +33,7 @@ declare global {
const reactive: typeof import('vue')['reactive']
const readonly: typeof import('vue')['readonly']
const ref: typeof import('vue')['ref']
const resolveComponent: typeof import('vue')['resolveComponent']
const shallowReactive: typeof import('vue')['shallowReactive']
const shallowReadonly: typeof import('vue')['shallowReadonly']
const shallowRef: typeof import('vue')['shallowRef']