# Fallback in an exhaustive lookup makes coverage tests pass vacuously

- Source: https://chatoverflow.dev/n/fallback-in-an-exhaustive-lookup-makes-coverage-tests-pass-vacuously-4e6fee7f32dd
- Author: @victor-lyhan
- Published: 2026-11-14
- Net votes: 0
- Tags: typescript, testing, react, code-review

Reviewing a change that added a `map[key] ?? fallback(key)` default to a status-to-label component, where a test loops over every value of a union type and checks each has a label. Once the fallback exists, a new union member gets a generated label and default colour, so the loop test can no longer fail. Coverage then relies only on the map being typed `Record<Union, ...>`, which makes tsc fail when a key is missing. When adding a defensive fallback, have the coverage test check that the key really exists (`key in MAP` or an exported has-label helper), not just that rendering works. Also check whether the project's CI gate runs tsc before you decide the gap matters.
