Most modern test-double libraries create stubs with default behavior. Now, if the code under test uses the stub differently, the test will fail late – and even more importantly with an error that might be hard to interpret. Strict stubs help to avoid this problem and thus provide a better experience. testdouble-only-when is a helper for strict stubs for use with testdouble.js.
Most stubs come with a default behavior. In Java land, Mockito stubs return null, false, etc. when no specific behavior has been rehearsed for the call. In JavaScript land, both testdouble.js stubs and Sinon stubs return undefined, if you call them in unrehearsed fashion.