Conformance
formancy ships more than one renderer. The obvious risk is that they drift: a
fix lands in React, Angular keeps the bug, and nobody notices for months.
@formancy/conformance exists to make that impossible.
One suite, N drivers
Section titled “One suite, N drivers”A behaviour is written down once, as data:
{ "name": "a conditional field appears when its condition turns true", "schema": { /* a real form */ }, "steps": [ { "set": { "country": "CH" } }, { "expectVisible": ["canton"] }, { "expectHidden": ["state"] }, { "submit": true }, { "expectErrors": { "canton": ["required"] } } ]}The same file then runs against the engine in Node, the engine in a browser, the React renderer, the Angular renderer and the server’s revalidation endpoint. Write it once, verify it in five places.
A renderer adapts itself to the suite through a small driver interface —
mount, fill, activate, visibleFields, valueOf, errorsFor,
currentPage, ariaSnapshot, submit — and then:
import { describeConformance } from '@formancy/conformance'import { describe, test } from 'vitest'
describeConformance(() => createMyDriver(), { test: { describe, test } })The test framework is passed as data rather than imported, so the suite runs under Vitest, Jest or Jasmine without the package depending on any of them.
The rule
Section titled “The rule”A driver resolves a field by accessible name and role. Nothing else.
getByRole('textbox', { name }), getByLabelText(name). Never a test id, never
a CSS selector, never a component instance.
The consequence is the entire point: a renderer whose markup cannot be queried by role and accessible name fails conformance. An input with no label, a combobox built from unlabelled divs, an error message not associated with its control — none of them can be driven, so none of them can pass. Accessibility stops being a workstream somebody schedules and becomes a structural property of a passing test run.
An error is said, and its code travels with it
Section titled “An error is said, and its code travels with it”A fixture asserts error codes — required, minLength — never wording, so it runs under any
language. A person reads a sentence instead (“Enter at least 5 characters.”), so the code cannot
be read from the words: each sentence carries it as data-formancy-code, inside the error
element the control’s aria-describedby points at. The driver finds that element through the
accessibility relation, as before, and reads the code where it is rather than parsing prose
(0191).
What the suite does assert about the words is only this: a message whose text is its own code fails, because that is a renderer drawing the engine’s vocabulary instead of saying it.
There will be a moment when a renderer is awkward to query and data-testid
looks like the pragmatic unblock. That escape hatch deletes the guarantee: the
suite would then pass over markup no screen reader can use, and it would keep
passing for years. If a control cannot be found by name and role, the bug is in
the renderer.
The fixture format backs this up mechanically — a case whose visible fields lack labels is rejected by the validator, so every runnable case carries the accessible names a driver must resolve by.
A fixture may also name the locale to mount in and the layout to draw the form with,
and a driver may ignore neither. The validator refuses one the document does not have: a
renderer falls back to the default locale, or to model order, and the case would then pass
while asserting nothing about either.
The renderer’s own controls — Next, Back, Submit, a row’s remove button, a ranking’s
buttons — carry no name in the fixture. The built-in drivers press them by the words the
renderer draws, read from @formancy/core/words in the locale the form was mounted in, so a
German form is driven through “Weiter” and “Absenden” and a renderer drawing “Next” there
fails. A driver for your own renderer reads whatever words your renderer draws
(0171).
What the shipped fixtures cover
Section titled “What the shipped fixtures cover”Each encodes semantics the engine and the renderers must implement, and
apps/docs/src/conformance-doc.test.ts holds this table to the fixtures directory:
| Fixture | What it pins |
|---|---|
| required field | submit blocked until a value exists |
| conditional visibility | a field appears and disappears with its condition |
| calculated value | a computed field tracks its inputs, and a value handed in for it is not shown or submitted |
| clear on hide | whether a hidden field’s answer is dropped or kept |
| repeating group | per-row validation, and re-indexing when a row is removed |
| repeater bounds | a repeater’s own error — too many rows for its maxItems, none where it is required — drawn on the repeater and read off its group by its legend |
| wizard page validation | next validates only the current page; submit validates everything and returns to the first page with a problem |
| wizard with layout | a paged form drawn with a layout shows the page somebody is on, arranged as the layout says, and leaves out what the layout leaves out |
| placed group | a group a layout places whole is drawn as its fields, on the page they are on — where both renderers threw |
| masked answer | a mask fills every position, and the answer holds only what was typed |
| temporal precision | a time or an instant with a precision keeps every digit it was given, byte for byte, stores typed digits at its width, and refuses an entry that stops short |
| select boxes | several answers from one list, stored in the list’s own order |
| ranking | the order chosen is the answer, and an untouched ranking holds nothing |
| matrix | a group per row of radios named by column, the answer per row, and a required one needs every row |
| translated labels | a form written in message references renders in its default locale |
| translated mounted locale | a form mounted in another locale renders in that one |
| renderer words mounted locale | a form mounted in another locale says Next, Back, Submit and a row’s and a ranking’s buttons in it too |
Failures are meant to be read by strangers
Section titled “Failures are meant to be read by strangers”A failure names the fixture, the step index, expected versus actual, and attaches an accessibility-tree snapshot taken at the moment it failed — because the person reading it is usually debugging a renderer they did not write and cannot see the screen. A driver that throws is reported as a crash, distinct from an assertion failure: one means the renderer behaves differently, the other means it broke.
Certifying your own renderer
Section titled “Certifying your own renderer”The package is published for exactly this. Implement the driver, run
describeConformance, and you have the same evidence the built-in renderers
have — that a Vue, Svelte or Solid renderer really does behave like the others,
rather than merely looking like it does.
Skips are deliberately loud: a skipped case either registers through the test framework’s own skip, or fails. A renderer must not be able to advertise conformance it does not have.