Skip to content

Make silencedConsole require explicit method selection #318

Description

@williamthorsen

Problem

silencedConsole() silences all five console methods (log, error, warn, info, debug) unconditionally. This masks unexpected console output that might reveal bugs, and developers default to silencing everything because it's the path of least resistance.

Context

The utility lives in packages/factory/src/test-utils.ts and is used across ~20 test call sites. Most callers only need to silence error (they're testing error paths). Three callers assert on specific methods (silent.error, silent.warn).

Solution

Make the methods parameter required so callers must specify which console methods to silence. The return type narrows to only include the requested methods, giving a compile-time error if a caller asserts on a method they didn't silence.

silencedConsole(['error'])        // → { error: MockInstance } & Disposable
silencedConsole(['error', 'warn']) // → { error: MockInstance; warn: MockInstance } & Disposable

All existing call sites move to silencedConsole(['error']). The three assertion sites keep their current method lists.

Acceptance criteria

  • silencedConsole requires an array of method names (no default "all" behavior)
  • Return type is narrowed to only the requested methods
  • All existing call sites updated
  • All tests pass

Metadata

Metadata

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions