LLMAssert
Matchers

toMatchTone

Assert that text matches a described tone or sentiment

Validates that text matches a natural-language description of the expected tone. Score 1.0 means a perfect tone match; 0.0 means the opposite tone.

Usage

await expect(response).toMatchTone("professional and helpful");
await expect(response).toMatchTone("empathetic", { threshold: 0.8 });

Negation

Verify a response avoids a specific tone:

await expect(response).not.toMatchTone("sarcastic or dismissive");

Example — brand voice check

import { test, expect } from "@llmassert/playwright";

test("support replies maintain professional tone", async () => {
  const response = await supportBot.reply("This product is terrible!");

  await expect(response).toMatchTone("empathetic and solution-oriented");
});

Effective tone descriptors

Use specific, descriptive phrases:

GoodToo vague
"professional and helpful""good"
"empathetic and solution-oriented""nice"
"concise and technical""short"
"warm and encouraging""positive"

Threshold guidance

ThresholdMeaningUse when
0.90Strict — tone must closely matchBrand voice compliance, customer-facing
0.75Balanced — right general toneInternal communications
0.70Default — allows tonal variationGeneral chatbots

Dashboard type

Appears as assertion type sentiment in the dashboard.

On this page