/dominiks-skills:write-component-testsfrom dominiks-skills
Write tests for UI components, pages, and hooks — language and framework agnostic. Covers semantic queries, user-journey naming, validation boundaries, RBAC, accessibility, and error-code coverage. Use when adding or improving tests for any UI codebase.
Ships in dominiks-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Write tests that describe what the user does and sees, not how the component is implemented. Skill is the discipline; the project supplies the runner (Vitest / Jest / Playwright / RTL / etc.).
Coding principles (always active): see coding-principles skill — Test Quality and Test Manager mindset.
TDD discipline (always active): see Pocock's tdd skill — one test → minimal impl → repeat.
Read the closest existing test file in the repo. Reuse:
beforeEach reset convention.If no example exists, that itself is a finding — surface it and propose a shared setup before scaffolding tests file by file.
Activate the Test Manager mindset (see coding-principles):
Output a test plan (mental or in the issue) before writing code.
Name tests as user stories, not implementation descriptions:
Good: editor can create a webhook and sees success message
viewer cannot see the delete button
shows validation error when URL exceeds 2048 characters
Bad: calls apiService.createWebhook with correct params
sets isLoading to true
renders component without errors
Structure files by user journey:
describe('WebhookFormDialog', () => {
describe('creating', () => { ... });
describe('editing', () => { ... });
describe('access control', () => { ... });
});
| Scenario | Approach |
|---|---|
| Loading | Make the API call return a never-resolving promise; assert progress role |
| Data renders | Mock resolved value; wait for the rendered text/role |
| Empty | Mock empty paginated response; assert role="status" |
| Error | Mock rejected value; assert role="alert" |
| Action menu | Click the trigger; find the menu by role; click the item |
| Dialog opens | Click the trigger; wait for role="dialog" |
| RBAC | Adjust the mocked auth context before render; assert hidden elements |
| API called | Assert the client method was invoked with the expected args |
| Required field | Submit empty; assert the required-validation message |
| Max length | Type over-boundary; assert max-length validation message |
| Wrong format | Type invalid format; assert format-validation message |
| Specific error code | Reject with {code: ERR_X}; assert the alert contains the mapped message |
| Escape closes | Press Escape; assert dialog gone |
| Enter submits | Focus submit; press Enter; assert the API call |
| Form labels | Find inputs by their accessible label |
| Reduced motion | Mock matchMedia to prefers-reduced-motion: reduce; assert no animation |
Names of APIs (getByRole, findByRole, userEvent, etc.) vary by runner — apply the equivalent in the project's tooling.
For every validated field, six tests:
| What | Example |
|---|---|
| Valid input | the canonical happy-path value |
| Empty / missing | required-validation error |
| Boundary min | exactly the minimum |
| Boundary max | exactly the maximum |
| Over boundary | one past the max → error |
| Wrong format | malformed input → format error |
For backend error codes, mock the rejection with the actual code shape and assert the user sees the specific mapped message — never let everything fall through to a generic "Something went wrong" assertion.
Prefer semantic queries (priority order):
If a test can't find an element by role, the element isn't accessible. That's a finding, not an excuse to switch to test IDs.
Cover keyboard navigation (Escape, Enter, arrow keys), focus management (dialog open/close, post-mutation focus), and reduced-motion preference where animations exist.
Match the project's convention. Common patterns:
<pages>/__tests__/<Page>.test.<ext> or <pages>/<Page>.test.<ext>__tests__ subfolder__tests__Mirror the real response shape exactly — including pagination envelopes ({data, meta} or {items, total} or whatever the project uses). Mismatched mocks make tests pass on imagined contracts.
it('renders correctly') covering everythingtdd for why this produces crap tests)What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
Generated from the plugin's indexed repository (dominikdorfstetter/skills) — no native marketplace selected
npx claudepluginhub p/dominikdorfstetter-dominiks-skills25 skills in this plugin
/add-backend-endpointAdd a new backend HTTP endpoint following the project's existing conventions — language and framework agnostic. Walks the layers (schema → repo → handler → routing → spec → client wiring), TDD-first. Use when adding a new API route to a backend codebase./add-list-pageScaffold a new CRUD list page in any frontend codebase — language and framework agnostic. Walks the layers (data fetch, mutations, RBAC, loading/empty/error, i18n, accessibility, UX polish), TDD-first. Use when adding a list/management page to a UI codebase./architect-reviewArchitectural evaluation of a codebase. Finds tech debt, missing patterns, coverage gaps, design inconsistencies; files parent + sub-issues via `gh`. Use when user asks for an architecture review, codebase evaluation, or wants to know what to fix structurally.