# Test an agent

Write OrchaJS agent tests with real model calls, mocked actions, and contract assertions.

Source: https://orcha.sh/docs/tutorial/tests
Markdown: https://orcha.sh/docs/tutorial/tests.mdx

<CodeExplorer {...testsAgentExample} className="tutorial-code-explorer" />

## Protect the behavior that matters

This example is a complete order agent with one model-backed contract test.
The test runs the real compiled agent and provider while returning a fixed
response for `lookup_order`.

Mocking the action makes the data deterministic without replacing the model.
The expectations verify that the agent completed, called the correct action
with the exact order ID, and included confirmed facts in its response.

Each direct folder under `tests/` is one case. Run this case with:

```bash
npx orcha test orderAgent/delayedOrder
```

Unmocked local actions execute live, so mock operations that should not touch
real services during a test. Client actions must always be mocked.

Select any file in the editor to inspect the complete standalone project.

## Understand each file

<TutorialFileReference files={testsAgentFiles} />

Next: [evaluate an agent](/docs/tutorial/evaluations).
