vitest-dev / vitest-dev/vitest
[Feature] Capture and fail on warnings
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
I found pytest's warning capture really useful, it captures warnings during tests and you can configure them to fail the tests.
https://docs.pytest.org/en/stable/how-to/capture-warnings.html
Combined with some NODE_OPTIONS like --pending-deprecation this could be a good way to prepare for node upgrades.
Suggested solution
Add a vitest option to capture warnings (process.on('warning')) and print them after a test run. Add options to fail tests on warnings.
Vitest could try to associate warnings with specific tests (which tests were running when the event was triggered, or which is in the stack trace)
Alternative
I think users could implement this themselves in a global setup file, but it would be easier to configure and recommend as a vitest feature.
Users could also use options like --throw-deprecation but we'd want to separate deprecation's thrown by vitest code from the application (i.e test workers). And seeing a completed test run with all deprecations at the end would be better than failing the test after the first deprecation.
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 Vitest's test-run and worker boundaries around process.on('warning'), global setup, and NODE_OPTIONS. Define how warnings are collected, printed after a run, and optionally treated as failures, including whether they can be associated with tests. Done means the configuration and behavior cover warnings from application code without prematurely stopping the run.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, typescript
- Domain
- testing-qa
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100