Skip to content

Examples ​

Start with behavior, then follow the code into the repository. Each example shows the smallest useful excerpt from both implementations when the ORM changes the expression of the pattern.

ExampleWhat it demonstratesStart here
Ordinary rollback testA write is visible now and absent in the next testRead the example
Fixtures + factoriesShared identities plus variation owned by one testRead the example
Authorization + tenancyFake identity; keep the database authorization decision realRead the example
Real concurrencyLeave the wrapper transaction when separate connections are the behaviorRead the example

These examples call endpoints in-process; see where that sits between unit and e2e tests.

The recurring shape ​

ts
it("exercises the real application", async () => {
  signInAs(fx.users.olivia);                    // replace identity lookup
  const record = await domainFactory.create(); // arrange test-owned variation
  const result = await serverFunction(record); // real auth + real queries
  expect(result).toEqual(expected);             // rollback follows automatically
});

There is no cleanup call in an ordinary test. Vitest's aroundEach owns the transaction, the application database import points at that transaction, and the harness forces a rollback after the assertion.

Browse the complete implementations ​

The excerpts explain the design; the repository tests are the executable authority.

A reference implementation to copy from, not a dependency.