Skip to content

Commit

Permalink
fix: always display serialized error, even if it doesn't have stack (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va authored Feb 8, 2023
1 parent 570c639 commit ab5f892
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
6 changes: 2 additions & 4 deletions packages/vitest/src/node/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,6 @@ function printStack(
errorProperties: Record<string, unknown>,
onStack?: ((stack: ParsedStack) => void),
) {
if (!stack.length)
return

const logger = ctx.logger

for (const frame of stack) {
Expand All @@ -200,7 +197,8 @@ function printStack(
logger.error(color(` ${c.dim(F_POINTER)} ${[frame.method, c.dim(`${path}:${frame.line}:${frame.column}`)].filter(Boolean).join(' ')}`))
onStack?.(frame)
}
logger.error()
if (stack.length)
logger.error()
const hasProperties = Object.keys(errorProperties).length > 0
if (hasProperties) {
logger.error(c.red(c.dim(divider())))
Expand Down
2 changes: 1 addition & 1 deletion packages/vitest/src/utils/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export function hasBenchmark(suite: Arrayable<Suite>): boolean {

export function hasFailedSnapshot(suite: Arrayable<Task>): boolean {
return getTests(suite).some((s) => {
return s.result?.errors?.some(e => e.message.match(/Snapshot .* mismatched/))
return s.result?.errors?.some(e => e && e.message && e.message.match(/Snapshot .* mismatched/))
})
}

Expand Down

0 comments on commit ab5f892

Please sign in to comment.