Conventions testing

From stella/stella · View interactive version

Conventions testing is an AI agent skill from the GitHub repository stella/stella. Apply when writing or reviewing tests, fixtures, seed data, demos or marketing recordings.

How to use this skill

Skill file

Testing Conventions

Apply when writing or reviewing tests.

What to test

Test when code has: parsing/transformation logic, security

boundaries, business rules with arithmetic, state machines,

non-obvious edge cases, or CRUD paths with auth, tenancy,

validation, serialization, uploads/downloads, or other side

effects. Skip: shallow CRUD handlers with no meaningful

branching, library wrappers, layout components, constants.

Prefer invariants over examples

When the input space is large (parsers, document transforms,

normalization, sorting/filtering, security boundaries,

Unicode-heavy logic), start by asking what must always be true,

then encode that as a property test, fuzzy test, or adversarial

regression test. Reach for ordinary example tests when they

communicate a business rule more clearly than a property.

Good property/fuzz targets in Stella: DOCX/OOXML roundtrips,

template/block-directive parsing, filename and header sanitization,

search/filter/sort helpers, tenant-scope enforcement, and error

normalization.

Structure

Colocate foo.test.ts next to foo.ts. For frontend, default

to extracting logic into foo.logic.ts and test that in Bun.

Use Playwright for browser-only behavior: auth redirects, route

guards, uploads/downloads, keyboard/focus, drag/drop, and

viewer/editor flows. Structural invariant tests (auth

enforcement, branded types) live in

apps/api/src/tests/security/.

Rules

Describe tests by behaviour, not by function name; prefer plain fakes over

mocking libraries for simple cases; and skip shallow examples that only raise

coverage when a stronger invariant test covers the same surface. Run tests

through the owning package script so preloads and setup survive:

bun run test -- --bail -t "<name>".

use Playwright for browser behavior. Do not add another test

runner without a clear gap Bun and Playwright cannot cover. [review]

beforeEach only for deterministic reset, and use expensive

shared fixtures only when explicit and isolated [review]

A test that only proves "does not throw" or re-encodes the production algorithm

needs a stronger assertion. [review]

contract. Do not use snapshots as a substitute for behavioral assertions.

[review]

highest meaningful layer, not only as pure helper tests [review]

prefer types, derivation, schemas, lint rules, or broader invariants when they

eliminate the bug class [review]

stale literal, or incidental implementation detail in a dedicated test when

structural coupling makes that failure impossible [review]

trusting it. A test that never reaches the fault, or matches zero tests, is

not a guard. [review]

actually match. Assert the fixture reaches or differs on the fault boundary

before asserting the protected outcome. [review]

are equal in both directions. Pin fixture literals that stand in for producer

output with satisfies against the producer's return type. [review]

tenant isolation, properties for parsers/normalizers, state-machine

transitions for lifecycle code, and round trips for serialization.

[review]

in tests. Pin or inject them rather than relying on ambient machine state.

[review]

Invented data that reads as real

Fixtures, seeds, e2e data, screenshots, demos and marketing recordings use

invented data that a lawyer would take for a real file: plausible personal and

firm names for the jurisdiction, real-looking addresses, case numbers, data-box

and registry IDs in their real formats, and dated, signed, coherent documents.

Real public institutions (courts, ministries, registries, data-box authorities)

appear under their real names. Private people, firms and their identifiers are

always invented, never a real person's or company's. Before using a

checksum-valid identifier (company ID, VAT number, birth number), check the

public registry that it belongs to no one.

"Acme", "John Doe", "Lorem ipsum", "[COMPANY NAME]", or local equivalents

such as "Vzorový", "Vzorová s.r.o." or "Jan Novák". The ratchet counts

placeholder names in tests, fixtures, seeds, browser specs and marketing

previews, and the count may only fall.

[check: ratchet:placeholder-party-names]

Mutation check

A test guarding behavior X is finished only once reverting X makes it fail.

Until you have seen it go red against the known-bad behavior, it may be

passing for an unrelated reason. When the test is the evidence for a fix,

say in the PR that you ran the mutation and what it broke.

The usual failure is a fixture the fault cannot reach. Assert the fixture

DIFFERS before asserting the equivalence: check

expect(NFD(word)).not.toBe(NFC(word)) before asserting both normalize alike,

so a fixture that is already normalized cannot make the test vacuous.

Cross-runtime contracts

Where one rule lives in two runtimes at once (JavaScript, Postgres, the search

engine), parity is proven only by DERIVING the other side's rules executably:

query the live extension for its token output, render the SQL the query layer

emits and assert on that, read the analyzer's configuration tuple.

A hand-maintained list mirroring the other side's behavior is not evidence of

parity. It is the drift, written down: it agrees with the other runtime exactly

until that runtime changes, and nothing fails when it does.

Projection census

Any "marked done" flag that mirrors state in an external system (search index,

object store, queue) ships with a reconciler that compares both sides and

reports the difference. Acceptance by the remote system is not durability, so

the flag alone can never prove the projection landed.

Treat the reconciler as part of the feature, not follow-up work: without it the

first divergence is invisible until a user reports missing data.

Property failure discipline

Use assertProperty(id, property, params?) from @stll/property-testing for

new properties; give it an explicit stable id matching the test title so the

printed bun test -t command selects the property. Keep arbitraries beside the

code under test. PR and merge-queue runs use deterministic seeds; exploratory

runs belong to the private nightly tier.

A failing seed is a real bug: fix it, then pin the seed and counterexample path

in packages/property-testing/property-seeds.json after the fix merges. Extend

the generator or oracle to cover the input class. Never rerun until green.

Use neutral public seed notes; report sensitive counterexamples privately.

When an oracle conflicts with a documented contract, the contract wins: adapt

the oracle rather than changing intended behavior.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.