TechWorkRamblings

by Mike Kalvas

202208112228 Types are not a substitute for tests

Type systems cannot and should not be viewed as a replacement for testing. Types cannot ensure that the code you wrote produces the actual outcome that you want it to. Tests on the other hand, can be used to verify and maintain that correctness.

Tests can never provide an unbroken chain of checks, from the database all the way to the frontend React props, guaranteeing that all of the data has the right shape [emphasis mine]. Types can't (usually) tell us when we accidentally put a "!" in front of a conditional. Focusing on one or the other means sacrificing quality, work efficiency, or both.1

Conversely 202208112226 Tests are not a substitute for types.


  1. Bernhardt, G. (2020, April 13). Execute Program. https://www.executeprogram.com/blog/are-tests-necessary-in-typescript