vitest-dev / vitest-dev/vitest
Expected behavior: `expect(() => { throw undefined }).toThrow('Input validation failed')` should fail.
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 17.1k
- Forks
- 2k
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 94
Description
Describe the bug
Encountered unexpected behavior where throwing undefined still passed the tests. This occurred because I created a mock function meant to check the error before throwing, but I forgot to implement the check.
Expected behavior: expect(() => { throw undefined }).toThrow('Input validation failed') should fail.
Reproduction
Expected behavior: expect(() => { throw undefined }).toThrow('Input validation failed') should fail.
System Info
System:
OS: Linux 6.8 Ubuntu 24.04.1 LTS 24.04.1 LTS (Noble Numbat)
CPU: (8) x64 Intel(R) Core(TM) i5-8265U CPU @ 1.60GHz
Memory: 2.06 GB / 7.57 GB
Container: Yes
Shell: 5.9 - /usr/bin/zsh
Binaries:
Node: 22.12.0 - ~/.nvm/versions/node/v22.12.0/bin/node
npm: 10.9.0 - ~/.nvm/versions/node/v22.12.0/bin/npm
pnpm: 9.15.2 - ~/.nvm/versions/node/v22.12.0/bin/pnpm
Browsers:
Chrome: 131.0.6778.264
npmPackages:
@vitest/coverage-v8: ^2.1.1 => 2.1.8
vitest: ^2.1.8 => 2.1.8
Used Package Manager
pnpm
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
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 reproducing the provided toThrow expectation with the repository's test runner, then locate the implementation and existing tests for toThrow. Add a regression test covering throw undefined with a non-empty expected message, and consider the issue complete when that expectation fails as described while existing matcher tests still pass.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- testing-qa
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100