Skip to content

fix: show assertion diffs from error causes - #839

Open
2lazzzy wants to merge 1 commit into
vitest-dev:mainfrom
2lazzzy:fix/659-error-cause-diff
Open

2lazzzy wants to merge 1 commit into
vitest-dev:mainfrom
2lazzzy:fix/659-error-cause-diff

Conversation

@2lazzzy

@2lazzzy 2lazzzy commented Nov 7, 2026

Copy link
Copy Markdown

Summary

When an assertion is wrapped in Error.cause, its message is shown but its actual/expected values are not available in the VS Code diff view. This addresses the remaining diff-display case discussed in #659.

- Use only the outer error's actual/expected values
+ Use the nearest complete actual/expected pair, starting with the outer error

Keep a single message with the full cause text and retain the outer error's stack, location, and copy-output association. Existing checks for missing values and serialized undefined still apply.

Evidence

  • Before: In the real VS Code test host, the new wrapped-assertion test fails with expected undefined to equal 'actual'.
  • After: All 26 unit tests pass, including 9 new cases covering cause diffs, outer-error precedence, nested causes, incomplete values, empty strings, metadata, and plain-message fallbacks.
  • pnpm typecheck, pnpm build, and pnpm fmt pass.
  • Tests ran in VS Code 1.145.2 on macOS. A temporary test configuration used short /tmp user-data and extensions paths to avoid the macOS socket path limit; it is not included in this PR.
  • Full E2E tests and manual visual inspection were not run.

Merge Danger

Door: Two-way; a localized change with no persistent data changes.

Blast Radius: Testing. Only the selection of diff values for reported test errors changes; the outer error still owns the message and navigation metadata.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants