From hoangsa
This skill should be used when the user is building, changing, or trying to verify a frontend feature on web (React/Vite) or React Native/Expo, and is unsure how to prove it actually works. Triggers on phrases like 'how do I test this component/screen', 'verify this feature', 'make sure this works on web/mobile', 'is this covered by tests', 'my tests pass but the feature is broken', 'no tests yet', or before shipping any FE change. Guides the full loop: define verifiable success criteria before coding, write tests at the correct layer (logic/component/E2E/visual), and confirm behavior by running the real app.
How this skill is triggered — by the user, by Claude, or both
Slash command
/hoangsa:fe-testingThis skill is limited to the following tools:
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
<objective>
Green tests that stay green when you break the code verify nothing. This skill drives the loop: define verifiable criteria BEFORE coding → pick the right test layer → write the test → run and watch the real app → prove the test is honest with a mutation check.
- "How do I test this component / screen / hook?" - "Verify this feature works" / "make sure it works on web/mobile" - "Is this covered by tests?" / "what should I test here?" - "My tests pass but the feature is broken" (false-green) - "There are no tests yet" / setting up FE testing from scratch - Building a new feature, form, list, navigation flow, or data-fetching screen - Before shipping / opening a PR on any FE change This skill is an application of CLAUDE.md §4 (Goal-Driven Execution) to frontend. The core rules:# web vs mobile, and existing test tooling
cat package.json 2>/dev/null | grep -A40 '"\(dependencies\|devDependencies\|scripts\)"'
ls vite.config.* app.json app.config.* metro.config.* playwright.config.* vitest.config.* jest.config.* 2>/dev/null
ls .maestro/ e2e/ 2>/dev/null
Classify:
vite/react-dom present. Expect Vitest + Testing Library + Playwright.react-native/expo present. Expect Jest (jest-expo) +
@testing-library/react-native + Maestro (or Detox).If no test tooling exists, see the setup sections in the reference files before writing tests — do not hand-roll a runner.
Turn the feature request into concrete, observable pass/fail checks BEFORE writing code. Write them down (in the plan, a comment, or the test file's `describe` block).Format each as Given / When / Then in user-observable terms:
Feature: "Add a save button to the profile form"
- Given a filled form, When I click Save, Then a success toast appears and the button is disabled while saving.
- Given a network error, When I click Save, Then an error message appears and the form stays editable.
- Given an empty required field, When I click Save, Then a field error shows and no request is sent.
Rules:
See references/verification-playbook.md for the criteria template and how to map each
criterion to a layer.
| Behavior under test | Layer | Web tool | Mobile tool |
|---|---|---|---|
| Pure function / hook logic, formatting, reducers | Unit | Vitest | Jest (jest-expo) |
| Component renders + responds to user input (types, clicks, shows error) | Component | @testing-library/react + user-event | @testing-library/react-native |
| Network-dependent component behavior | Component + mocked network | MSW | MSW / jest.mock fetch |
| Multi-screen flow, navigation, real routing/persistence | E2E | Playwright | Maestro (preferred) or Detox |
| Exact pixels / layout / visual regression | Visual | Playwright screenshot | Maestro screenshot / device screenshot |
Guidance:
references/web-testing.md (Vitest, Testing Library queries, user-event, MSW,
Playwright).references/mobile-testing.md (Jest/jest-expo, RNTL, Maestro flows, Detox).Non-negotiables regardless of stack:
data-testid, or component internals. (testID/data-testid only as a last
resort for elements with no accessible handle.)user-event on web, fireEvent/RNTL on mobile), not by
calling handlers directly.Web:
npm run dev & # or the project's dev script; note the URL/port
# Then drive it with Playwright (headed or screenshot) and read the screenshot back:
npx playwright test --headed # if E2E specs exist
# or a one-off screenshot script — see references/web-testing.md "observe" section
Prefer the built-in verify and run skills to boot and drive the app, and visual-debug
to turn screenshots/recordings into an annotated montage for inspection.
Mobile (Expo):
npx expo start & # boot Metro
# Maestro drives the simulator and can screenshot each step:
maestro test .maestro/<flow>.yaml
Maestro's takeScreenshot steps + the visual-debug skill give you frame-by-frame evidence.
Walk your criteria list from flow 2 and tick each one off against what you actually see. If a criterion can't be observed, it isn't done.
Prove the test is honest before you trust it. For each new test:A test you've only ever seen pass is a hypothesis. This 30-second step is the difference between "tests pass" and "feature verified".
| Rule | Detail | |------|--------| | **Criteria before code** | Write observable Given/When/Then checks before implementing. No criteria → nothing to verify. | | **Two legs** | Every feature needs a red-on-break automated test AND a real-app observation. One alone is not "verified". | | **Behavior over implementation** | Assert what the user/API observes. Never assert internal state, prop names, or CSS classes. | | **Query like a user** | Role / label / text / a11y. `testID`/`data-testid` is a last resort, not a default. | | **Cheapest honest layer** | Push each check to the lowest pyramid layer that still exercises real behavior. | | **Mock only the network** | Mock at the fetch/HTTP boundary (MSW). Never stub your own modules to make a test pass. | | **Mutation check** | A new test must be seen failing (break the code) before it's trusted. | | **Detect, don't assume** | Detect web vs mobile and existing tooling from the repo before writing tests. | - **`references/web-testing.md`** — Web setup (Vitest + Testing Library + `user-event` + MSW + Playwright), idiomatic component/E2E examples, and the "observe the real app" recipe. - **`references/mobile-testing.md`** — React Native/Expo setup (`jest-expo` + `@testing-library/react-native`, Maestro flows, Detox), device/simulator observation, and screenshot evidence. - **`references/verification-playbook.md`** — The pre-code criteria template, criterion→layer mapping worksheet, and the false-green anti-pattern catalog (what makes tests lie).Creates structured, bite-sized implementation plans from specs or requirements before writing code. Useful for breaking down multi-step tasks into testable steps with file structure and task boundaries.
npx claudepluginhub unknown-studio-dev/hoangsa --plugin hoangsa