Cookbook
Short, copy-pasteable recipes for the scenarios that come up in every Stimulus project. Each page is self-contained: one problem, one solution, one complete test.
Recipes
- Testing values — defaults, overrides, programmatic changes, value changed callbacks.
- Testing targets & classes —
hasXTarget,xTargets, class bookkeeping. - Testing outlets — two controllers, one DOM, one test.
- Mocking fetch — happy path, error path, request assertions.
- Fake timers — debounce, throttle,
setTimeout,setInterval. - Form validation — dispatched events, error targets,
novalidate. - Keyboard & a11y —
getByRole, key grammar,aria-expanded, focus traps.
If you have a scenario not covered here, open an issue or a PR on GitHub.