Skip to content

Commit

Permalink
fix(vitest): json reporter location should include file
Browse files Browse the repository at this point in the history
  • Loading branch information
vird committed Feb 2, 2024
1 parent ae73f27 commit 4915030
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/vitest/src/node/reporters/json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { parseErrorStacktrace } from '../../utils/source-map'

type Status = 'passed' | 'failed' | 'skipped' | 'pending' | 'todo' | 'disabled'
type Milliseconds = number
interface Callsite { line: number; column: number }
interface Callsite { line: number; column: number; file: string }
const StatusMap: Record<TaskState, Status> = {
fail: 'failed',
only: 'pending',
Expand Down Expand Up @@ -193,6 +193,9 @@ export class JsonReporter implements Reporter {
if (!frame)
return

return { line: frame.line, column: frame.column }
let file = ''
if (error.stacks && error.stacks.length)
file = error.stacks[0].file
return { line: frame.line, column: frame.column, file }
}
}

0 comments on commit 4915030

Please sign in to comment.