It Should Help

Methods

The verifier for functions: should().method(fn) checks that invoking the function throws — or that it completes and hands the produced value back for further chains.

should().method(fn).throws(...)

should().method(() => service.cancel(id)).throws(); should().method(() => service.get(id)).not.throws();

throws(...args) invokes the function with the given arguments and passes when the call throws any exception. not.throws() is the readable replacement for a hand-rolled "called and nothing exploded" try/catch.

returns(...args) — run and keep the value

returns(...args) invokes the function, asserts that it completes without throwing, and returns the produced value — the bridge from a method check back to the typed verifiers:

const age = should().method(() => user.age).returns(); should().number(age).positive();

Under not, returns() asserts the opposite — the invocation must throw — and yields undefined.

Definedness

Like every verifier, should().method(null).throws() throws The entry is not defined. regardless of not; use defined()/not.defined() when the function itself may be absent — a not-yet-assigned callback, an optional dependency.

When to use what

Situation

Use

The call must fail

method(fn).throws()

The call must succeed and the value matters

method(fn).returns() + a typed verifier

The call must succeed and the value does not matter

method(fn).not.throws()

Signatures and messages

See API reference — Method verifier.

16 September 2026