# Test results

A test run that leads with what failed. Passing tests fold into a count. Coverage shows against what a production deploy requires, and only once the run has measured it.

- Registry name: `test-results` (`@candor/test-results`)
- Tier: Pro. Installing it needs a Pro, Premium or Team licence key: the person runs `npx candor-ui key <key>` themselves; never ask for the key in chat or write it to a file.
- Docs: https://candor.themethodic.com/docs/test-results

## Install

```bash
npx candor-ui add test-results
```

Run `npx candor-ui@latest init` once first (https://candor.themethodic.com/get-started.md). Without the CLI: `npx shadcn@latest add @candor/test-results`.
It brings in: collapsible, locale, streaming-text, work, utils.
npm packages: lucide-react@^1.67.0.

## Example

```tsx
"use client"

import type { TestRun } from "@/lib/work"
import { TestResults } from "@/components/test-results"

const run: TestRun = {
  status: "failed",
  duration: "48s",
  coverage: 0.71,
  coverageRequired: 0.75,
  cases: [
    { id: "t1", className: "customers/region.test.ts", method: "sets region from billing country", outcome: "fail", duration: "1.2s", message: "Expected: eu, Received: other", stack: "at Object.<anonymous> (api/src/customers/region.test.ts:48:5)" },
    { id: "t2", className: "customers/region.test.ts", method: "keeps region when already set", outcome: "pass", duration: "0.4s" },
    { id: "t3", className: "customers/region.test.ts", method: "bulk insert of 200 rows", outcome: "pass", duration: "3.1s" },
    { id: "t4", className: "routing/assign-region.test.ts", method: "routes by region", outcome: "pass", duration: "0.9s" },
    { id: "t5", className: "routing/assign-region.test.ts", method: "falls back to partner tier", outcome: "skip" },
  ],
}

export default function Example() {
  return <TestResults className="max-w-2xl" run={run} />
}
```

## <TestResults>

Props:

- `run: TestRun`: The test run: its status, cases and, once measured, coverage against what's required.
- `className?: string | undefined`

## Strings (`testResults`)

The fixed words, English by default. Override any of them under `testResults` in `<LocaleProvider strings={{ testResults: { … } }}>`; the table is exported as `testResultsStrings`.

- `label`: Test results
- `running`: Running tests
- `someFailed`: { one: "{failed} of {count} test failed", other: "{failed} of {count} tests failed" }
- `allPassed`: { one: "All {count} test passed", other: "All {count} tests passed" }
- `passed`: {count} passed
- `failed`: {count} failed
- `skipped`: {count} skipped
- `passedAndSkipped`: {passed} passed, {skipped} skipped
- `coverage`: Coverage
- `measuring`: Measuring
- `notMeasured`: Not measured
- `belowRequired`: Below the {percent} production needs
- `required`: Production needs {percent}
- `failedIcon`: Failed
- `passedIcon`: Passed
- `skippedIcon`: Skipped

## Rules for using Candor UI

- Components take plain typed data. Never pass model output as HTML or render it as a link; messages are typed blocks.
- A control that can't be used says why: wrap it in `<Locked reason="…">`, don't just disable it.
- Don't show a value you don't have: leave it out (it renders as —) rather than guess. An estimate is labelled as one.
- Nothing is pre-selected in a decision a person makes, and the agent is named from your app's data, never from model output.
- Your app's words go in `LocaleProvider` (fixed strings) and `TermsProvider` (nouns); entity kinds and agent roles in `EntityKindsProvider` and `AgentRolesProvider`.
