Trace Helpers
Trace helpers read a harness run. First-party harnesses attach native spans
when provider/runtime data exposes real operations. Custom harnesses created
with createHarness() get a fallback run span unless they return their own
traces.
Span Checks
Section titled “Span Checks”Use trace helpers for operational behavior that is not represented by output, messages, or tool calls.
import { expect } from "vitest";import { failedSpans, spansByKind,} from "vitest-evals";
expect(spansByKind(result, "model").length).toBeGreaterThan(0);expect(failedSpans(result)).toHaveLength(0);Use spans(result) when you need the full flattened span list. The helpers also
accept a normalized trace array when that is the only value available.
import { spans } from "vitest-evals";
expect(spans(result).some((span) => span.status === "error")).toBe(false);API Links
Section titled “API Links”| Helper | Use |
|---|---|
spans | Flatten every span from a run. |
spansByKind | Filter spans by run, model, tool, or another span kind. |
failedSpans | Read spans with error status or normalized errors. |