A tiny zero-dependency TypeScript library (v0.8.0) that forces console.error/warn and network requests (fetch, XMLHttpRequest) to throw exceptions, failing tests or code paths early. Designed to catch React warnings like 'act(...)' or unmounted component updates, and unmocked network calls. Works in Node.js (>=14) and browsers. < 100 lines, fully tested, alternative to jest-fail-on-console with broader scope (not Jest-specific).
npm install throw-onNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to enable throw-on for console.error, console.warn, and fetch in a test setup, including the ignore option.
Use named imports from the package, not from subpaths.
Always call restoreConsole in test teardown (e.g., afterEach) to avoid side effects.
Manually mock fetch in tests instead of using throwOnFetch if you need selective behavior.
Use throwOnFetch instead, as XMLHttpRequest is legacy.
Run npm install --save-dev throw-on and ensure tsconfig.json includes node module resolution.
Either fix the code causing the console.error, or add the message to the ignore list.
Use import { throwOnConsole } from 'throw-on' (curly braces).No dependency data recorded yet.