vitest-dev / vitest-dev/vitest

`ExpectationResult` of a custom asymmetric matcher is ignored

Open
#7,730 12 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

pending triage
Dominant language
TypeScript
Stars
17.1k
Forks
2k
Avg merge
1d 22h
Merged PRs (30d)
94

Description

Describe the bug

When I have a custom asymmetric matcher, Vitest applies it correctly but disregards the matcher's ExpectationResult properties like message, actual, and expected if the matcher fails. I expect the inverse assertions (.not) to have the same problem.

Reproduction

Here's a sandbox: https://stackblitz.com/edit/vitest-dev-vitest-je43znvc?file=vite.config.ts,vitest.setup.ts,test%2Fbasic.test.ts&initialPath=__vitest__/

System Info
Irrelevant.
Used Package Manager

npm

Validations

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked StackBlitz reproduction, especially vite.config.ts, vitest.setup.ts, and test/basic.test.ts, and run the failing custom asymmetric matcher case. Trace how the matcher’s ExpectationResult is handled on failure and verify that message, actual, and expected are preserved for both normal and inverse assertions.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
56/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.