> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stateset.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Synthetic Fixtures for Agent Testing

> Create deterministic test data locally and use it to verify commerce and agent outcomes.

Start with small synthetic fixtures whose expected results you can calculate independently.
This guide runs locally; it does not require a hosted Synthetic Data Studio. The earlier Studio
host and API examples were not backed by a published service contract and have been removed.

## Generate a repeatable fixture

Use Node.js **20.20.0+**. Save this as `generate-fixture.mjs` in a new directory:

```javascript theme={null}
import assert from 'node:assert/strict';
import { writeFileSync } from 'node:fs';

const orders = Array.from({ length: 10 }, (_, i) => ({
  reference: `fixture-order-${i + 1}`,
  email: `buyer-${i + 1}@example.com`,
  sku: 'MUG-001',
  quantity: i + 1,
  unitPrice: '12.50',
  currency: 'USD',
}));
const totalCents = orders.reduce((sum, order) => sum + BigInt(order.quantity) * 1250n, 0n);
assert.equal(totalCents, 68750n);
const expected = { orders: 10, units: 55, currency: 'USD', total: '687.50' };
writeFileSync('orders.fixture.json', JSON.stringify({ orders, expected }, null, 2), { flag: 'wx' });
console.log('Wrote 10 synthetic orders: 55 units, 687.50 USD');
```

```bash theme={null}
node generate-fixture.mjs
```

**Success:** the script writes `orders.fixture.json` and prints the expected count and total.
It refuses to overwrite an existing file. Prices are represented as decimal strings; the
calculation uses integer cents rather than floating-point addition.

These are input fixtures, not API request bodies or persisted commerce records. Map them to
the exact binding’s schema before importing them. The [orders quickstart](https://docs.stateset.com/guides/orders-quickstart.md)
shows the tested customer, inventory, and order creation sequence.

## Cover decisions, not just volume

| Scenario | Expected behavior |
| - | - |
| Enough inventory | Order created and allocation independently checked |
| Insufficient inventory | Documented rejection without an unintended allocation |
| Missing customer or record | Clear missing-data result, no invented replacement |
| Duplicate submission | Endpoint-specific replay or conflict behavior |
| Uncertain payment result | Reconcile the provider result before another attempt |
| Out-of-policy customer request | Escalation or refusal supported by the policy source |

Use the [error-handling tests](https://docs.stateset.com/guides/error-handling-best-practices.md) for concrete rejection
checks and [agent evaluations](https://docs.stateset.com/guides/first-agent-evaluation.md) for expected conversational behavior.

## Keep a test record

Record the fixture version, environment, package version, expected results, and the IDs created
by the run. Use separate databases and workspaces for tests. Synthetic data can still trigger
real delivery or payment actions if connected to live tools; configure the execution boundary.

> [!NOTE]
>
> Synthetic fixtures are not evidence of production representativeness or a privacy guarantee.
> Review any imported source data and independently verify what connected tools can execute.

## Continue

Run the [first local operation](https://docs.stateset.com/guides/first-operation.md), then add the edge cases above to the
[integration test plan](https://docs.stateset.com/guides/comprehensive-testing-guide.md). Keep fixtures and their expected
results under version control so failures can be reproduced.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.