It Should Help

General Assertions

The checks that are not tied to one type: boolean-context truthiness on the factory, and definedness on every verifier.

should().true(value)/should().false(value)

Assert how the value behaves in a boolean context. Falsy values are exactly: false, 0, '', null, undefined, and NaN — everything else is truthy.

should().true(15); // ok — numbers other than 0 are truthy should().true('non-empty'); // ok should().false(1 > 4); // ok should().false(0); // ok — 0 is falsy should().false(null); // ok should().true(0); // throws 'The entry expected to be true.'

These are terminal checks (no chaining after them) and have no not form — use the opposite verb instead. Prefer them over expect(Boolean(x)).toBe(true) when the point of the test is the truthiness itself; prefer a specific verifier (string, number) whenever the type is known — the failure messages will say something useful.

defined() — on every verifier

Every verifier — number, string, array, date, objects — exposes defined(). It passes when the examined entry is neither null nor undefined and otherwise throws The entry is not defined.. It is also the guard every other check runs implicitly; see Concepts for the interaction with not.

should().string(maybeConfig).defined(); should().array(backendResponse).defined().length(2);

not.defined() is the single legal way a null/undefined entry passes a chain:

should().string(pendingValue).not.defined(); // ok when pendingValue is null/undefined

When to use what

Situation

Use

The type is known

the typed verifier, not true()/false()

Only "is it there" matters

defined()/not.defined()

A flag-like result of any type

true()/false()

Next: the typed chapters — Numbers, Strings, Dates, Arrays, Objects.

02 сентября 2026