← ClaudeAtlas

part-factory-test-datalisted

Build test data with @kensio/part-factory, keeping in the factory everything a test does not care about, passing dependencies at call time so factories stay independent, and choosing between StaticFactory, DynamicFactory, VariantFactory, MappedFactory and AsyncMappedFactory. Use when writing test fixtures or builders, when a test file is full of object literals, when a shared event, message or payload shape is being hand-written, when a required field is about to be made optional to ease test setup, and when tempted to wrap a factory in a helper function that applies overrides.
KensioSoftware/kensio.ai · ★ 1 · Data & Documents · score 72
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