Component Story
An isolated rendered instance of a component, usable as documentation, a workbench, and a test.
A component story is a single named example of a component in a particular state, rendered in isolation. The pattern is most associated with Storybook, where stories serve three purposes at once: a development workbench, living documentation, and — when they carry an interaction script and assertions — a test.
The third use is the one that changes how a suite is structured. A story that drives real interactions in a real browser tests focus, layout, styling, and accessibility, none of which a simulated DOM can evaluate honestly. For anything visual, a story is a better test than a unit test.
Practical hazards worth knowing:
- Portalled content is not inside the component's container, so a query scoped to that container will not find an open menu or dialog. Query the document instead. See Portal.
- The runner has a default canvas width that is rarely the round number you would guess, so a responsive element can be absent by default. Pin a viewport where width matters.
- Documentation tooling can silently overwrite a spread configuration object, dropping opt-outs — and that tooling frequently does not run under the test runner, so no assertion inside a story can ever catch it.
- Navigating away — clicking a real link — tears down the runner's page and silently skips the remaining files.
See also7
Hand-picked in the note itself — the neighbours worth reading next.
Visual Regression Testing
Comparing rendered output against a stored baseline to catch unintended visual change.
Testing & Verification10 connections
Headless Browser
A real browser driven programmatically without a visible window.
Testing & Verification10 connections
Integration Test
A test exercising several components together, through real interfaces rather than doubles.
Testing & Verification9 connections
Accessibility
Designing so that people with disabilities can use a thing, and the standards that make it checkable.
Design & Interface20 connections
Reduced Motion
An operating-system preference signalling that animation should be minimised, for real medical reasons.
Design & Interface10 connections
Responsive Breakpoint
A viewport width at which a layout changes, and the assumptions that come with it.
Design & Interface7 connections
Focus Management
Deliberately controlling which element receives keyboard focus as an interface changes.
Design & Interface14 connections
Related2
Nearby in the graph rather than deliberately chosen. Looser, sometimes surprising.
Linked from13
Notes elsewhere in the wiki that reach for this one.
- contenteditableWeb Platform
The HTML attribute that makes an element directly editable, and the surface behind most rich-text editors.
- EasingDesign & Interface
The curve mapping elapsed time to progress, and the main reason motion feels right or wrong.
- Focus ManagementDesign & Interface
Deliberately controlling which element receives keyboard focus as an interface changes.
- Headless BrowserTesting & Verification
A real browser driven programmatically without a visible window.
- Integration TestTesting & Verification
A test exercising several components together, through real interfaces rather than doubles.
- Motion DesignDesign & Interface
Using movement to communicate change, continuity, and hierarchy rather than to decorate.
- PortalWeb Platform
Rendering an element into a different part of the document than its logical parent.
- Reduced MotionDesign & Interface
An operating-system preference signalling that animation should be minimised, for real medical reasons.
- Responsive BreakpointDesign & Interface
A viewport width at which a layout changes, and the assumptions that come with it.
- Stacking ContextDesign & Interface
The nested coordinate system that decides what paints above what, and why z-index often does nothing.
- Staggered AnimationDesign & Interface
Offsetting the start of sibling animations so a group reveals in sequence.
- Unit TestTesting & Verification
A fast, isolated test of one unit of behaviour with its collaborators replaced.
- Visual Regression TestingTesting & Verification
Comparing rendered output against a stored baseline to catch unintended visual change.