[Feature] Capture and fail on warnings
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
- [x] Follow our Code of Conduct
- [x] Read the Contributing Guidelines.
- [x] Read the docs.
- [x] Check that there isn't already an issue that request the same feature to avoid creating a duplicate.