It Should Help

Dates

should().date(x) verifies a date. Everywhere a date is expected you may pass either a Date instance or an ISO string — the verifier normalizes both.

Equality with accuracy

equals(expected, accuracy?) compares both dates truncated to the given accuracy. The ladder is 'year' | 'month' | 'day' | 'hour' | 'minute' | 'second' | 'millisecond' (default: 'millisecond' — exact).

const actual = '2024-05-06T10:00:00.000Z'; should().date(actual).equals('2024-05-06T22:15:30.500Z', 'day'); // ok — same calendar day should().date(actual).equals('2024-05-06T22:15:30.500Z', 'hour'); // throws — 10h vs 22h should().date(actual).equals(new Date(actual)); // ok — exact, Date accepted should().date(actual).equals('2024-05-06T10:00:00.001Z'); // throws — differs by 1 ms

Accuracy answers "did it happen that day/month" without date arithmetic in the test.

Before and after

should().date('2024-05-06T10:00:00Z').before('2024-05-20T10:00:00Z'); // ok should().date('2024-05-06T10:00:00Z').before('2024-05-06T10:00:00Z'); // throws — border is exclusive should().date('2024-05-06T10:00:00Z').after('2024-05-01T00:00:00Z'); // ok

Borders are exclusive: "before" is strictly <, "after" is strictly >.

Ranges

should().date('2024-05-06T10:00:00Z').inRange('2024-05-01T00:00:00Z', '2024-05-31T00:00:00Z'); // ok should().date('2024-04-20T10:00:00Z').inRange('2024-05-01T00:00:00Z', '2024-05-31T00:00:00Z'); // throws — below min

Both borders are exclusive, like before and after.

Negation

should().date('2024-05-06T10:00:00Z').not.before('2024-05-01T00:00:00Z'); // ok should().date('2024-05-06T10:00:00Z').not.equals('2024-05-06T10:00:00Z', 'day'); // throws

The null/undefined rules from Concepts apply (an unparseable string becomes an Invalid Date, not null — see Caveats).

Signatures and messages

See API reference — Date verifier.

02 сентября 2026