console-fail-test is a utility library designed to enforce clean testing practices by automatically failing individual test runs if any console methods (e.g., console.log, console.warn, console.error) are invoked during their execution. The current stable version is 0.6.1, with a release cadence that focuses on minor updates for dependency maintenance, bug fixes, and broader test runner compatibility. A key differentiator is its framework-agnostic integration through a setup file, supporting popular test runners like Jest, Vitest, Mocha, and Ava. It provides detailed summaries of all console calls, including arguments, upon test failure, helping developers quickly identify and rectify unintended outputs. The library ensures that failures are reported *after* tests complete, allowing other test failures to surface normally, preventing test suites from passing when they shouldn't due to overlooked console messages. It's strictly ESM-only since version 0.6.0 and requires Node.js >=20.19.0.
npm install console-fail-testVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to integrate `console-fail-test` into a Jest project using `setupFilesAfterEnv` and illustrates how a `console.log` call within a test will lead to a test failure.
Update your test runner configuration to use the new, unified ESM path: `console-fail-test/setup`. If you were using `console-fail-test/setup.cjs` or `console-fail-test/setup.mjs`, these paths are no longer valid. Ensure your project's environment and test runner setup are configured for ESM compatibility.
Upgrade your Node.js runtime to version `20.19.0` or newer to be compatible with this package version. Older Node.js versions will likely encounter compatibility errors.
Proactively remove all unnecessary `console.*` calls from your tests and the code under test. If console output is intentionally part of a test scenario (e.g., testing that a utility *does* log a warning), you might need to use test-runner specific features to temporarily disable or mock console methods for that particular test.
Configuration is exclusively via the test runner's setup mechanism (e.g., `setupFilesAfterEnv` for Jest/Vitest). Ensure the `console-fail-test/setup` file is correctly listed in your test runner's configuration.
Locate the offending `console.*` call in your test file or the application code being tested and remove it. If the console output is expected for specific testing scenarios, consult your test runner's documentation for ways to mock or temporarily disable console methods.
Update your test runner configuration to refer to the current ESM-only setup path: `console-fail-test/setup`.
Ensure your project and test runner are configured for an ESM environment. This might involve setting `"type": "module"` in your `package.json` or configuring your test runner (e.g., Jest's `preset`) to handle ESM. Avoid `require()` for this package entirely.
No dependency data recorded yet.