vitest-dev / vitest-dev/vitest

Test: standardize tests for all matchers

Open
#9,074 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

contributing 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

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

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 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.