part-factory-test-datalisted
Install: claude install-skill KensioSoftware/kensio.ai
# Building test data with Part Factory
[Part Factory](https://partfactory.dev/) (`@kensio/part-factory`) builds typed objects for tests. A
factory holds the defaults, and `make(overrides)` returns an object with the overrides applied down
through the nested structure.
The package README is the authority on the API. This skill covers what to put in a factory, where
factories should live, and which one to reach for.
It serves the `isolated-testing-style` skill. Factories are what make building state inside each
test cheap enough that nobody reaches for a shared fixture in the first place.
## Say only what the test is about
A factory defines every value the test ignores. The test can state only the values it does. That is
the whole point of one.
Without it, a test opens with twenty lines of construction and it is unclear which of them the
assertions actually depend on. With it, the lines that are there are the lines that matter:
```typescript
it("charges VAT on the order total", () => {
// Given an order whose lines add up to a total the assertion depends on.
const order = orderFactory.make({ lines: [{ price: 1000 }, { price: 2000 }] });
// When it is priced.
const priced = priceOrder(order);
// Then VAT is a fifth of that total.
expect(priced.vat).toBe(600);
});
```
The prices are written down because the assertion is arithmetic on them. The order id, the customer
id and the dates stay with the factory, because the test would read the same whatever they we