testing-patterns
Skill by davila7
testing-patterns gives an AI assistant Jest testing patterns for unit tests. It covers factory functions, mocking strategies and a TDD red-green-refactor workflow. It is for developers who write unit tests and want consistent test data and mocks.
Install testing-patterns
Built from the published package, never by AI.
git clone --depth 1 https://github.com/davila7/claude-code-templates /tmp/claude-code-templates && mkdir -p ~/.claude/skills && cp -r /tmp/claude-code-templates/cli-tool/components/skills/development/testing-patterns ~/.claude/skills/testing-patternsRun in your terminal. Claude Code loads skills from ~/.claude/skills automatically.
git clone --depth 1 https://github.com/davila7/claude-code-templates /tmp/claude-code-templates && mkdir -p ~/.gemini/antigravity-cli/skills && cp -r /tmp/claude-code-templates/cli-tool/components/skills/development/testing-patterns ~/.gemini/antigravity-cli/skills/testing-patternsAntigravity CLI loads skills from ~/.gemini/antigravity-cli/skills, or .agents/skills for one project.
Skills can run scripts on your machine. Some need an API key: check the README.
About
testing-patterns is an agent skill, defined in a SKILL.md file, that guides an AI assistant in writing Jest unit tests. It covers a test-driven development workflow, factory functions for component props and data, and mocking strategies for modules and GraphQL hooks. It also includes a custom render helper that wraps components with providers, plus examples of test structure, queries and user interactions.
The skill is a set of patterns and code samples rather than a tool that runs anything itself. The examples use @testing-library/react-native and show getByText, queryByText and fireEvent. It also lists anti-patterns, such as testing mock behavior instead of real behavior and duplicating test data instead of using factories. It is aimed at developers who write unit tests and want reusable, consistent test setup.
Written from the project's SKILL.md and checked against it.
What it can do
- TDD workflowGuides writing a failing test first, minimal code to pass, then refactoring after green.
- Custom render functionWraps components with required providers, shown with a ThemeProvider example.
- Component props factoryProvides getMockX-style functions with sensible defaults and overridable properties.
- Data factoryBuilds typed mock objects, such as a user, that can be overridden per test.
- Module mockingShows jest.mock for whole modules and for modules with a factory function.
- GraphQL hook mockingMocks generated query hooks and sets return values such as loading and data per test.
- Test structureShows describe and it blocks organized by rendering, interactions and edge cases.
- Query patternsShows getByText, queryByText and waitFor for elements that appear asynchronously.
- User interaction patternsShows fireEvent calls for entering text and pressing a button in a form test.
- Anti-patternsLists mistakes to avoid, such as testing mock calls and skipping factories.
What you need
- Jest
- @testing-library/react-native
- npm (examples run tests with npm test)
Try asking
- Write a failing Jest test for my LoginForm before I implement it.
- Create a getMockUser factory for my User type with an admin override.
- Mock my useGetItemsQuery hook and test the loading state.
Good to know
- Provides patterns and code samples, not executable code.
- Sample paths such as utils/testUtils and ThemeProvider are project-specific.
Security check
ANo download-and-run commands, hidden instructions or signs of sending keys out were found.
Checked automatically: cli-tool/components/skills/development/testing-patterns/SKILL.md. This looks for known risky patterns and is not a full audit. How grades work
Inside the skill
-
SKILL.md6 KB
Alternatives to testing-patterns
All alternatives →Runs a 7-stage workflow for auditing, cleaning up and reviewing GitHub repositories, plus competitor analysis. Written for developers who want a repo checked for secrets, junk files and documentation gaps.
Teaches an AI assistant to build, debug and explain Gradio web UIs and ML demos in Python. It covers the core API, components, event listeners, layouts and the MCP server option. Aimed at Python developers who work with Gradio.
Recommends menus, buttons, toolbars and disclosure controls for Apple platforms using Human Interface Guidelines conventions. Built for developers and designers making iOS, iPadOS, macOS or visionOS interfaces. Checks existing project design context before asking questions.
Creates production-ready FastAPI project structures with async patterns, dependency injection, and error handling. It is for developers starting new FastAPI applications or backend API projects.
Analyzes Android apps to find user workflows to expose as AppFunctions, so AI agents and system shortcuts can run them without opening the app UI. Generates Kotlin code and refines KDoc for Android developers.
Creates, edits, validates and runs Agent QA tests, suites and hooks through MCP or CLI. It keeps canonical IDs and schema contracts intact, for developers and QA teams using Agent QA.
Compare with openclaw-github-repo-commander, gradio or hig-components-menus
testing-patterns: common questions
Does this skill follow test-driven development?
Yes. It says to write a failing test first, implement minimal code to pass it, and refactor after green.
What testing libraries does it use?
The examples use Jest and @testing-library/react-native.
What is a factory function in this skill?
It is a function named like getMockX that takes optional overrides, provides sensible defaults and lets a test change specific properties.
How do I install testing-patterns?
Run the command above to copy the skill into ~/.claude/skills/. Claude Code picks it up automatically.
Is testing-patterns free?
The code is published under the MIT licence. The service it connects to may have its own pricing.
Is testing-patterns safe to use?
It scores 91 of 100. Grades: maintenance A, licence A, quality A. Security check: grade A, no risky patterns found in the files checked. Review the code before you install. How grades work.
What are alternatives to testing-patterns?
Similar skills: openclaw-github-repo-commander, gradio, hig-components-menus, fastapi-templates.
