# Role tests

URL: /code/file-conventions/role-tests · Id: `page:code/file-conventions/role-tests`

> A Role test file holds the eval cases a Role's agent must pass, and autonomy climbs per Verb on its results.

A file named `[role].test.ts` beside a [Role](/business/nouns/role) holds the eval cases its agent must pass. Autonomy climbs per [Verb](/business/nouns/verb), from assist to full, on these results.

```text
agents/customer/
├── success-manager.mdx
└── success-manager.test.ts
```

## Reference
TypeScript with `test`, `expect` and `run` from `startup-builder/test`. `run` drives the Role with recorded model output, so CI makes no model call.

| Export | Type | Holds |
| --- | --- | --- |
| `test(name, fn)` | function | One case |
| `run(task, stubs)` | function | Gives the Role one [Task](/business/nouns/task) and returns `{ result, calls }` |
| `expect(value)` | function | Assertions, and `toPass(evaluator)` to grade with an [Evaluator](/business/nouns/evaluator) |

## Examples
### Minimal
```ts title="agents/customer/success-manager.test.ts"
import { expect, run, test } from 'startup-builder/test'

test('sends the notice', async () => {
  const { calls } = await run({ lease: 'lease_1', daysLeft: 60 })
  expect(calls).toContain('Lease.notify')
})
```

### Leaseline
```ts title="agents/customer/success-manager.test.ts"
import { expect, run, test } from 'startup-builder/test'

test('never quotes a rent the manager has not set', async () => {
  const { result } = await run({ question: 'Can you do $1,700 instead?', lease: 'lease_1' })
  expect(result.reply).toPass('evaluators/notice-tone')
  expect(result.calls).not.toContain('Lease.renew')
})
```

## What it builds
The [StartupBuilder](/code/builders/startup) runs the cases on every preview of the Role.

- a verdict per case on the [Change](/business/nouns/change)
- the Role's autonomy per Verb: assist, supervised or full
- a failing case demotes the Verb one level until it passes

## Good to know
- Autonomy is per Verb, not per agent: one agent may send notices alone and still ask before renewing.