LLMAssert
Matchers

Matchers

Overview of all 5 LLM assertion matchers

LLMAssert provides 5 assertion matchers. All return { pass: boolean, score: number | null, reasoning: string } and support .not negation.

MatcherWhat it checksScore meaning
toBeGroundedInEvery claim is supported by the context1.0 = fully grounded, 0.0 = fabricated
toBeFreeOfPIINo personally identifiable information1.0 = no PII, 0.0 = definite PII
toMatchToneMatches a described tone/sentiment1.0 = perfect match, 0.0 = opposite tone
toBeFormatCompliantConforms to a described structure1.0 = fully compliant, 0.0 = wrong structure
toSemanticMatchSemantically similar to reference text1.0 = identical meaning, 0.0 = unrelated

Common patterns

All matchers accept an optional threshold override:

await expect(response).toBeGroundedIn(context, { threshold: 0.9 });

All matchers support .not negation:

await expect(creativeResponse).not.toBeGroundedIn(context);

A null score means the evaluation was inconclusive (judge unavailable) — the test passes rather than producing a false failure.

Default threshold

All matchers use 0.7 as the default threshold. Scores at or above the threshold pass.

Threshold sources (highest priority first):

  1. Inline{ threshold: 0.9 } passed to the matcher
  2. Remote — configured per-assertion-type in the dashboard
  3. Default — 0.7

See Thresholds for detailed guidance on choosing values per matcher.

On this page