Back to Plate

Warning-path React specs should capture debug.warn in their harness

docs/solutions/test-failures/2026-03-25-warning-path-react-specs-should-capture-debug-warn-in-their-harness.md

53.0.5899 B
Original Source

Warning-path React specs should capture debug.warn in their harness

Problem

A broad Bun run was green, but useElementStore.spec.tsx sprayed a wall of USE_ELEMENT_CONTEXT warnings into the output.

The spec intentionally rendered consumers outside ElementProvider, so the warnings were expected behavior. The noisy part was the test harness, not the runtime code.

Fix

Override the core debug plugin in the spec harness and replace logger.warn with a no-op for that test editor:

  • use DebugPlugin.ts
  • configure logger.warn
  • keep the runtime warning path intact

Rule

If a React spec intentionally hits a warning path, capture debug.warn in the spec harness.

Do not mute the runtime globally and do not leave expected warnings spamming broad Bun runs.