/bulletproof-react-skills:testingfrom bulletproof-react-skills
Testing strategy conventions from bulletproof-react: when to reach for a unit vs. integration vs. e2e test, and the recommended tooling (Vitest, Testing Library, Playwright, MSW) for each. Use this whenever adding tests to a React app, deciding what kind of test a piece of code actually needs, or reviewing a PR's test coverage — especially when the default has been "add a unit test" without considering whether an integration test would give more real confidence. Reach for this when the user asks things like "what kind of test should this component have", "should I mock the API for this test", or "how do I set up e2e tests for this app".
Ships in bulletproof-react-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.
Adapted from bulletproof-react @
9506629, MIT licensed. See ../../NOTICE.md for provenance and the re-pin workflow.
Prioritize integration and e2e coverage over unit tests when deciding where to invest testing effort — as this tweet argues, that's where the real confidence in application functionality comes from. Unit tests still have a place for isolating individual components, but don't treat them as the primary source of confidence.
Reach for these to isolate a single shared component/function used throughout the app, or to test complex logic inside one component. They're fast to run and easy to write, but don't rely on them alone — passing unit tests don't prove the connections between parts of your app actually work.
Favor integration tests for most of your testing effort — they check how different parts of the application work together, which is what actually matters for reliability. A component passing its unit test doesn't mean the app works if the connections between components are broken, so test features (not just isolated parts) with integration tests to ensure the app works smoothly and consistently.
Use e2e tests to evaluate the application as a whole. Automate the complete application — frontend and backend together — to confirm the entire system functions correctly, simulating how a real user would interact with it.
Use Vitest as the test runner. It offers features similar to Jest but is more up to date, works well with modern tooling, and is highly customizable and flexible.
Use Testing Library and follow its philosophy: test the app the way a real user experiences it, not its implementation details. Don't assert on a component's internal state value — assert on what it renders to the screen. This way, if you refactor the app to a different state management solution, the tests stay relevant because the user-facing output hasn't changed.
Use Playwright to run e2e tests in an automated way: define the commands a real user would execute against the app, then run them. It supports 2 modes — pick based on context:
Use MSW to prototype and mock the API layer. It doesn't run an actual backend: in the browser it intercepts requests via a Service Worker (setupWorker), and in Node.js test runs — including under Vitest — it uses setupServer instead, since there's no Service Worker in that environment. Either way you define the same handlers and it returns the responses you specify. Reach for it when you're blocked by unfinished backend work: instead of waiting on the feature or hardcoding response data in your frontend code, define handlers and make real HTTP calls against the mock while building frontend features.
Use it to design API endpoints too — put the mocked API's business logic in its handlers.
A fully functional mocked API server also pays off in tests: instead of mocking fetch, make requests to the mocked server with the data your application expects.
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub dfadler/bulletproof-react-skills --plugin bulletproof-react-skills7 skills in this plugin
/components-and-stylingComponent and styling conventions from bulletproof-react: colocation,
avoiding nested render functions, container/presentation separation, and
composition-over-config for component APIs. Covers when to reach for a
fully-styled vs. headless component library, which styling solution fits
a given setup (including React Server Components constraints), and using
Storybook for isolated component development. Use this when designing a
new component's API, reviewing a component for prop bloat or nested
render functions, choosing a component library or styling approach for a
project, or when a request looks like "this component is taking too many
props, how should I split it up," "what component library should I use
for this dashboard," or "where should I put this piece of state/style so
it doesn't cause unnecessary re-renders."
/performancePerformance conventions from bulletproof-react: code splitting,
component/state update optimization, list virtualization, image
optimization, and bundle analysis. Use when a React app feels slow or before
shipping a feature that renders large lists or heavy assets. Reach for this
whenever you're about to add a route, decide where a piece of state should
live, render a list of unknown or large size, or add images — and whenever
a request mentions phrasing like "this page feels slow", "why is this
component re-rendering so much", or "how should I load these images".
/project-standardsProject standards from bulletproof-react: ESLint/Prettier/TypeScript config,
absolute imports, pre-commit hooks, and CI conventions. Use when setting up
tooling for a React project or reviewing its lint/format/type configuration.
Reach for this whenever asked to "set up linting for a new React project,"
"configure absolute imports so I stop seeing ../../../," "add a pre-commit
hook to run lint and type-check," or "review this project's ESLint/Prettier/
tsconfig setup" — or when enforcing consistent file/folder naming conventions
across a codebase.
/project-structureProject structure conventions from bulletproof-react: what lives in src/,
the app/assets/components/features/hooks/lib/stores/testing/types/utils
layout, and how features are organized to stay unidirectional. Use when
scaffolding a new React project, deciding where a new file belongs, reviewing
a PR that imports across feature boundaries, or setting up ESLint import
restrictions — for example "where should this component/hook/API call live",
"should this be shared or feature-scoped", or "is this cross-feature import
okay".
/securitySecurity conventions from bulletproof-react: token storage and
authentication for SPAs, authorization patterns, and other client-side
hardening practices. Use when implementing auth, authorization checks, or
handling sensitive data in a React app. Reach for this whenever a task
involves deciding where to store a JWT after login, wiring up route/component
guards so only certain roles can see a feature, restricting an action (like
deleting a comment) to its owner, or reviewing a PR that touches
authentication/authorization code — for example "where should I store the
auth token", "how do I hide this button from non-admins", "only the comment
author should be able to delete it", or "is this login flow XSS-safe".
/state-and-dataState management and data-fetching conventions from bulletproof-react:
component vs. application vs. server vs. form vs. URL state, a single shared
API client instance, colocated request declarations paired with React Query
hooks, and API/in-app error handling. Use when adding state, wiring up an
API call, or handling request/render errors in a React app. Reach for this
whenever you're about to decide "should this be useState or global state?",
add a new fetch/mutation to a React app, wire up form validation, or figure
out where a caught error should surface — e.g. "where should I put this
modal's open/closed state?", "how do I fetch and cache this list from the
API?", "the app crashed on one bad component and took the whole page down
with it."