Filter out stdout/stderr messages
See original GitHub issueClear and concise description of the problem
I’m working on a LitHtml project and when you run it in development mode it logs a message to the console, that appears when I do test runs:
stderr | unknown test
Lit is in dev mode. Not recommended for production!
See https://lit.dev/msg/dev-mode for more informat
ion.
When running my tests, I get this multiple times and it provides no value. I know I can use --silent
to ignore all output, but I do want to see any other messages.
Suggested solution
I was picturing a configuration setting that you could set:
{
ignoreConsoleMessages: {
source: 'stderr' // 'stdout' | 'stderr'
match: /Lit is in dev mode/
}
}
Or similar. That way the developer can very explicitly ignore certain messages, but can still see all other messages.
If this is acceptable, I would be happy to make an attempt at implementation in a PR 👍
Alternative
I think I could solve this in user-land by using a stubbing library such as sinon, and mock the console methods. But I think this is something worth considering solving in the configuration layer.
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.
Issue Analytics
- State:
- Created a year ago
- Reactions:3
- Comments:13 (2 by maintainers)
It appears you can now also do this with a (currently undocumented) option in your vite/vitest config:
@nicooprat I had the same issue as you – not being able to disable the productionTip/devtools logging. After messing with the config for a bit, I was able to finally disable the logs by creating a
vitest.setup.js
containing this:and then adding this to my
vitest.config.js
: