vitest-dev / vitest-dev/vitest
Test: standardize tests for all matchers
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
Currently, matchers tests are all over the place. We do not have tests for all possible errors produced by matchers.
Suggested solution
I think we should have a separate test/matchers folder. Tests for all matchers should also include the final message, not just call the matcher and be done with it. We want to make sure the error message is helpful.
test('matcher works', () => {
expect(2).not.toBe(1) // bad test
// better test -- maybe even use fuzzy
const error = throws(() => expect(2).toBe(1))
expect(error.diff).toBe('...')
expect(error.message).toBe('...')
expect(error.actual).toBe('2')
expect(error.expected).toBe('1')
})
Having coverage for it should help us catch all the missing tests too.
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 inventorying the existing matcher tests and compare their locations with the proposed test/matchers folder. Run the matcher test suite, then standardize coverage so each matcher checks its final message, diff, actual value, and expected value where applicable; done means missing error cases are covered.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- testing
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100