WeSearch

vitest-fail-on-console: Stop Ignoring console.error in Your Tests

·3 min read · 0 reactions · 0 comments · 1 view
#testing#vitest#javascript#console#development
vitest-fail-on-console: Stop Ignoring console.error in Your Tests
⚡ TL;DR · AI summary

The article introduces vitest-fail-on-console, a tool that causes tests to fail when console.error or console.warn messages appear during testing, promoting cleaner and more intentional test output. It highlights how ignored console messages can mask underlying issues even when tests pass. The tool is configurable and integrates easily into existing Vitest setups.

Key facts
Original article
DEV.to (Top)
Read full at DEV.to (Top) →
Opening excerpt (first ~120 words) tap to expand

try { if(localStorage) { let currentUser = localStorage.getItem('current_user'); if (currentUser) { currentUser = JSON.parse(currentUser); if (currentUser.id === 50274) { document.getElementById('article-show-container').classList.add('current-user-is-article-author'); } } } } catch (e) { console.error(e); } Recca Tsai Posted on May 2 • Originally published at recca0120.github.io vitest-fail-on-console: Stop Ignoring console.error in Your Tests #testing #vitest #node Originally published at recca0120.github.io All tests pass, but the terminal is full of red console.error output. This is common and easy to ignore — the tests passed, after all. But those errors don't appear out of nowhere. Something went wrong; nobody just noticed.

Excerpt limited to ~120 words for fair-use compliance. The full article is at DEV.to (Top).

Anonymous · no account needed
Share 𝕏 Facebook Reddit LinkedIn Threads WhatsApp Bluesky Mastodon Email

Discussion

0 comments

More from DEV.to (Top)