frontend-testing
Skill8 starsChanged 3 months agoMITView on GitHub
Activate this skill when: - Writing new unit or integration tests for React components, hooks, utilities, or Zustand stores - Reviewing existing tests for correctness, coverage, or best practices - Improving test coverage for under-tested modules - Debugging flaky or failing tests - Refactoring test code for maintainability Test files follow one of two patterns: Naming convention: ComponentName.test.tsx for components, hook-name.test.ts for hooks, util-name.test.ts for utilities. Do NOT use .spec.tsx -- while technically matched, the project convention is .test.tsx.
18 other projects use a version of this, 2 of them edited.
Adopted by
Most recently taken up by
- LongJohnSilver1504/claude-skillstheir own version, first seen Nov 8, 2026
- theexperiencecompany/gaiatheir own version, first seen Nov 3, 2026
- YosemiteCrew/Yosemite-Crewtheir own version, first seen Nov 1, 2026
- langgenius/difytheir own version, first seen Oct 29, 2026
- aboio-labs/aboio-skillstheir own version, first seen Oct 13, 2026
- nightscout/nocturnetheir own version, first seen Oct 8, 2026
Used with
Projects with it also use receiving-code-review.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
CloudflareSkillreceiving-code-review
Use when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementation
Also in 4 projects that use this
Other versions18 projects use a version of this.
Word for word · 0
None found.
Edited · 2
- langflow-ai/langflow★ 156k98% same
- factor241/ketos-bot★ 198% same
Wrote their own version · 16
- langgenius/dify★ 161ksame name
- YFGaia/dify-plus★ 2.3ksame name
- YosemiteCrew/Yosemite-Crew★ 2ksame name
- Ohh-889/skyroc-admin★ 795same name
- theexperiencecompany/gaia★ 325same name
- mcowger/plexus★ 239same name
- nightscout/nocturne★ 163same name
- nilecui/SkillsBase★ 27same name
- bestdeejay-design/agent-skills★ 6same name
- aboio-labs/aboio-skills★ 3same name
6 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository13 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .cursor/rules/docs_development.mdcCursor rule
- backend-code-reviewSkill
- component-refactoringSkill
- e2e-testingSkill
- frontend-code-reviewSkill
- frontend-i18nSkill
- frontend-query-mutationSkill
- ibm-a11y-level1-auditSkill
- ibm-a11y-pr-remediationSkill
- ibm-a11y-route-scanSkill
- ibm-a11y-testing-guideSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
14 rules. 0 are common, 10 are distinctive, and 4 are very specific to this project.
0
Common
Most of the 18 edited versions we read keep these.
10
Distinctive
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 62
Test files follow one of two patterns:
- Distinctive: line 132
When testing a directory with multiple files, follow this order:
- Distinctive: line 157
Default rendering / initial state
- Distinctive: line 168
Every test should have a clear three-phase structure.
- Very specific: line 171
Test the component from the user's perspective.
- Distinctive: line 177
Use descriptive names that explain the expected behavior:
- Distinctive: line 188
Default render with no optional props
- Distinctive: line 231
Verify that deleting a flow does NOT delete flows from other users
- Distinctive: line 232
Verify that a read-only user CANNOT trigger write mutations
- Distinctive: line 233
Verify that XSS payloads in user input are sanitized
- Distinctive: line 258
Run coverage for a specific file:
- Very specific: line 265
Never use Vitest APIs: Use jest.fn(), jest.mock(), jest.spyOn(), jest.mocked() -- never vi.* equivalents.
- Very specific: line 269
Wrap state updates in
act(): when testing Zustand stores or React state changes. - Very specific: line 270
Clean up after each test: Use beforeEach(() => jest.clearAllMocks()) and afterEach for timers.
“Common” is measured: kept by at least 6 in 10 of the 18 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Frontend Testing Skill - Langflow
When to Apply
Activate this skill when:
- Writing new unit or integration tests for React components, hooks, utilities, or Zustand stores
- Reviewing existing tests for correctness, coverage, or best practices
- Improving test coverage for under-tested modules
- Debugging flaky or failing tests
- Refactoring test code for maintainability
Tech Stack
| Technology | Version | Purpose |
| Jest | 30.x | Test runner and assertion framework |
| ts-jest | 29.x | TypeScript transform for Jest |
| React Testing Library | 16.x | Component rendering and DOM queries |
| @testing-library/user-event | 14.x | Realistic user interaction simulation |
| @testing-library/jest-dom | 6.x | Extended DOM matchers |
| jsdom | (via jest-environment-jsdom 30.x) | Browser environment simulation |
| React | 19.x | UI framework |
| TypeScript | 5.4 | Type safety |
| Zustand | 4.x | State management |
| React Router DOM | 6.x | Client-side routing |
| @tanstack/react-query | 5.x | Server state management |
| Axios | 1.x | HTTP client |
Project Configuration
- Jest config:
src/frontend/jest.config.js - Setup files:
src/frontend/jest.setup.js(globals/mocks) andsrc/frontend/src/setupTests.ts(DOM matchers, ResizeObserver, IntersectionObserver, matchMedia) - Path alias:
@/maps to<rootDir>/src/ - Test match patterns:
src/**/__tests__/**/*.{test,spec}.{ts,tsx}andsrc/**/*.{test,spec}.{ts,tsx} - Transform: Custom
transform-import-meta.jshandlesimport.metafor Jest compatibility - Global mocks (in
jest.setup.js):@radix-ui/react-form,react-markdown,remark-gfm,remark-math,rehype-mathjax/browser,lucide-react/dynamicIconImports,@/components/common/genericIconComponent,@/icons/BotMessageSquare,@/stores/darkStore,localStorage,sessionStorage,crypto
Key Commands
# Run all tests
npm test
# Run a specific test file
npm test -- path/to/file.test.tsx
# Run tests matching a pattern
npm test -- --testPathPattern="alertStore"
# Run tests in watch mode
npm run test:watch
# Run tests with coverage
npm run test:coverage
# Run a single test file with coverage
npm test -- --coverage --collectCoverageFrom='src/path/to/source.ts' path/to/__tests__/source.test.tsFile Naming and Location
Test files follow one of two patterns:
- Dedicated
__tests__directory (preferred for components and modules):src/components/core/my-component/ ├── my-component.tsx └── __tests__/ └── my-component.test.tsx - Co-located test file (acceptable for utilities and simple modules):
src/utils/ ├── myUtil.ts └── myUtil.test.ts
Naming convention: ComponentName.test.tsx for components, hook-name.test.ts for hooks, util-name.test.ts for utilities.
Do NOT use .spec.tsx -- while technically matched, the project convention is .test.tsx.
Test Structure Template
import { render, screen } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import MyComponent from "../MyComponent";
// Mock dependencies (use jest.mock, NOT vi.mock)
jest.mock("@/controllers/API/api", () => ({
get: jest.fn(),
post: jest.fn(),
}));
describe("MyComponent", () => {
beforeEach(() => {
jest.clearAllMocks();
});
describe("rendering", () => {
it("should render the component with default props", () => {
// Arrange
render(<MyComponent />);
// Act - (none for render test)
// Assert
expect(screen.getByRole("button", { name: /submit/i })).toBeInTheDocument();
});
});
describe("user interactions", () => {
it("should call onSubmit when the form is submitted", async () => {
// Arrange
const user = userEvent.setup();
const onSubmit = jest.fn();
render(<MyComponent onSubmit={onSubmit} />);
// Act
await user.click(screen.getByRole("button", { name: /submit/i }));
// Assert
expect(onSubmit).toHaveBeenCalledTimes(1);
});
});
});Incremental Testing Workflow
When testing a directory with multiple files, follow this order:
- Identify all source files in the target directory
- Order by complexity (simplest first):
- Pure utility functions (no React, no side effects)
- Constants and configuration objects
- Custom hooks (no UI rendering)
- Simple presentational components (no state, no side effects)
- Stateful components with local state
- Components using Zustand stores
- Components with API calls or complex async behavior
- Integration-level components that compose many children
- For each file: a. Read the source file completely b. Identify all exported functions, components, and types c. Write tests covering all branches and edge cases d. Run the tests and fix any failures e. Check coverage and add tests for uncovered lines f. Move to the next file
- Run full directory coverage at the end to verify
Complexity-Based Test Ordering
Within a single test file, order test cases from simplest to most complex:
- Default rendering / initial state
- Props variations and conditional rendering
- User interactions (clicks, typing, form submission)
- Async operations (API calls, timers)
- Error states and edge cases
- Integration with stores or context
- Cleanup and unmount behavior
Core Principles
Arrange-Act-Assert (AAA)
Every test should have a clear three-phase structure. Use blank lines to separate each phase for readability.
Black-Box Testing
Test the component from the user's perspective. Query by role, label, text, or data-testid -- never by CSS class, internal state variable, or implementation detail.
Single Behavior Per Test
Each it() block should verify exactly one behavior. If you need to write "and" in the test name, split it into two tests.
Semantic Test Names
Use descriptive names that explain the expected behavior:
- Good:
"should disable the submit button when the form is invalid" - Bad:
"button test"or"test 1"
Format: "should [expected behavior] when [condition]"
Required Test Scenarios
For every component, cover at minimum:
Rendering
- Default render with no optional props
- Render with all optional props provided
- Conditional rendering branches (if/else in JSX)
Props and State
- Each prop variation that changes rendered output
- Default prop values
- State transitions triggered by user actions
User Interactions
- Click handlers
- Form input and submission
- Keyboard navigation (if applicable)
- Hover/focus states (if applicable)
Challenge Tests (MANDATORY — not optional)
Happy path tests alone are NOT enough. They only confirm the code works when everything is perfect. Real bugs hide in the cracks. You MUST write tests that actively TRY TO BREAK the code:
Unexpected inputs:
null,undefined,"",[],{},0,-1,NaN,Infinity- What happens when a required prop is missing?
- What happens when data from the API comes back with missing fields?
Boundary values:
- Max length strings (paste 10,000 chars in an input)
- Exactly at the limit, one past the limit
- Zero items, one item, maximum items
- First page, last page, out-of-range page
Malformed data:
- API returns
{ data: null }instead of{ data: [] } - JSON with extra unexpected fields
- Dates in wrong format, numbers as strings
Error states:
- Network failure (API rejects with 500)
- Authentication expired mid-action (401)
- Resource not found (404)
- Permission denied (403)
- Timeout
What should NOT happen:
- Verify that deleting a flow does NOT delete flows from other users
- Verify that a read-only user CANNOT trigger write mutations
- Verify that XSS payloads in user input are sanitized
Rapid/concurrent actions:
- Double-click on submit button
- Rapid repeated API calls
- Unmount component while async operation is in flight
Write tests based on REQUIREMENTS, not on what the source code does. This is how you catch bugs where the code diverges from expected behavior.
When a test fails: first ask if the CODE is wrong, not the test. Do NOT silently change a failing assertion to match the current code without understanding WHY.
Async Behavior
- Loading states
- Success states
- Error states
- Timeout/retry behavior
Coverage Goals
Per source file:
- Function coverage: 100%
- Branch coverage: > 95%
- Line coverage: > 95%
- Statement coverage: > 95%
Run coverage for a specific file:
npm test -- --coverage --collectCoverageFrom='src/path/to/file.ts' src/path/to/__tests__/file.test.tsImportant Rules
- Never use Vitest APIs: Use
jest.fn(),jest.mock(),jest.spyOn(),jest.mocked()-- nevervi.*equivalents. - Never mock base UI components from
@/components/ui/-- render them as-is. - Check
jest.setup.jsbefore mocking: Many modules are already globally mocked (darkStore, genericIconComponent, react-markdown, radix-form, etc.). Do not re-mock them. - Use
@testing-library/user-eventoverfireEventfor user interactions. - Wrap state updates in
act()when testing Zustand stores or React state changes. - Clean up after each test: Use
beforeEach(() => jest.clearAllMocks())andafterEachfor timers. - Always write both happy path AND adversarial tests (null, undefined, empty values, boundary conditions, error states).
- Minimum coverage: 75% (target 80%). Below 75% the task is not complete.
Forbidden Test Anti-Patterns
| Pattern | Problem | How to Detect |
| The Liar | Test passes but doesn't verify the behavior it claims to test | Assertions don't match the test name |
| The Mirror | Test reads source code and asserts exactly what the code does — finds zero bugs | Test would never fail even if logic changes |
| The Giant | 50+ lines of setup, multiple acts, dozens of assertions | Should be 5+ separate tests |
| The Mockery | So many mocks that the test only tests the mock setup | Count mocks — if > 3 deep, rethink |
| The Inspector | Coupled to implementation details, breaks on any refactor | Tests internal state instead of behavior |
| The Chain Gang | Tests depend on execution order or share mutable state | Tests fail when run in isolation |
| The Flaky | Sometimes passes, sometimes fails with no code changes | Non-deterministic assertions or timing issues |
References
- Incremental Testing Workflow - Step-by-step process for testing directories
- Mocking Guide - Patterns for mocking APIs, stores, routers, and context
- Async Testing - Patterns for async operations, timers, and waitFor
- Common Patterns - Query priority, events, forms, modals, data-driven tests
- Test Checklist - Pre-submission verification checklist
- Domain Components - Langflow-specific component testing patterns
- Component Template - Starter template for component tests
- Hook Template - Starter template for hook tests
- Utility Template - Starter template for utility tests
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

