vitest-dev / vitest-dev/vitest
Create a `diff` on the main thread
Nobody has claimed this yet.
- 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
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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