vitest-dev / vitest-dev/vitest

Create a `diff` on the main thread

Open
#9,583 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

p2-nice-to-have
Dominant language
TypeScript
Stars
17.1k
Forks
2k
Avg merge
1d 22h
Merged PRs (30d)
94

Description

Clear and concise description of the problem

We already put prettified actual/received on every error that has a diff. We could just compare them on the main thread without needed to import the diff library (which takes ~15ms for every test file on M3 Macbook)

Suggested solution

Rewrite diff logic to be called on the main thread and save everyone some time when importing vitest. One issues I see at the moment is that this.utils.diff is a public API in extended matchers. I wonder if it would make sense to turn it into a CJS module that calls require inside utils.diff function to avoid breaking changes.

At the same time we could log a warning to return actual/expected instead of calling the diff manually (vitest creates a diff automatically then)

Alternative

No response

Additional context

No response

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 by tracing the public this.utils.diff API in the extended matchers documentation and the current diff-library import path. Determine how main-thread comparison affects that API and verify that the diff library is no longer imported for every test file, while preserving or deliberately warning about the existing behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
testing-qa
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.