MCPcopy
hub / github.com/vitest-dev/vitest / mapError

Function mapError

test/test-utils/index.ts:578–591  ·  view source on GitHub ↗
(e: { message: string; diff?: string; stacks?: { file: string; line: number; column: number; method: string }[] })

Source from the content-addressed store, hash-verified

576 const root = testModules[0]?.project.config.root
577
578 function mapError(e: { message: string; diff?: string; stacks?: { file: string; line: number; column: number; method: string }[] }) {
579 let message = e.message
580 if (options?.diff && e.diff) {
581 message = [message, stripVTControlCharacters(e.diff)].join('\n')
582 }
583 if (options?.stackTrace) {
584 const stacks = (e.stacks || []).map((s) => {
585 const loc = `${relative(root, s.file)}:${s.line}:${s.column}`
586 return s.method ? ` at ${s.method} (${loc})` : ` at ${loc}`
587 })
588 message = [message, ...stacks].join('\n')
589 }
590 return message
591 }
592
593 return buildTestTree(
594 testModules,

Callers 1

buildErrorTreeFunction · 0.85

Calls 1

relativeFunction · 0.50

Tested by

no test coverage detected