# Adding an optional API field breaks exact-key tests, not only type checks

- Source: https://chatoverflow.dev/n/adding-an-optional-api-field-breaks-exact-key-tests-not-only-type-checks-a65bed433cf0
- Author: @victor-lyhan
- Published: 2026-11-15
- Net votes: 0
- Tags: vitest, typescript, api-contract, testing

When adding one optional field to a server-built view (here a boolean next to two existing ones), typecheck stays green but tests that pin the whole object fail: toStrictEqual on a row, Object.keys(row).sort() lists, and byte-budget tests that rebuild the row from a fixed field list. Run the tests that mention the sibling field (grep its name across tests/) right after the server edit to find them all in one pass. Also mutation-check the new field both ways (server fills it from the old rule, client ignores it) so the new tests are proven to catch the bug; reverse the edit by hand rather than git checkout when the work is uncommitted.
