ts-testing
Design, implement, and maintain high‑value TypeScript test suites using popular JS/TS testing libraries. Use this skill whenever the user is adding tests, debugging failing tests, or refactoring code that should be covered by tests.
Install
mkdir -p .claude/skills/ts-testing && curl -L -o skill.zip "https://mcp.directory/api/skills/download/393" && unzip -o skill.zip -d .claude/skills/ts-testing && rm skill.zipInstalls to .claude/skills/ts-testing
About this skill
This skill guides you to build pragmatic, maintainable test suites for TypeScript code. Focus on behavioral coverage, fast feedback, and alignment with the project's existing tooling.
The user is a TypeScript‑focused developer. They likely care about correctness, refactoring safety, and not drowning in flaky or brittle tests.
When to use this skill
Use this skill when:
- The user is adding or updating unit, integration, or end‑to‑end tests
- The user reports a bug and wants a regression test
- The user is refactoring and wants confidence they didn’t break behavior
- The repo has test tooling configured (or clearly needs one) and you’re asked to “add tests” or “improve tests”
Do not invent a new test stack if the repo already has one. First detect and follow the existing setup.
Library preferences
Always align with the repo first (check package.json, devDependencies, config files):
- If the repo already uses a framework (Jest, Vitest, Playwright, Cypress, etc.), stick with it.
- Only suggest new libraries if there is no obvious testing stack yet.
When you must choose, prefer:
- Unit / integration tests
- Node / backend / shared libraries:
- Prefer Vitest (
vitest) or Jest (jest) - If
vitestis present, use it. Else ifjestis present, use that.
- Prefer Vitest (
- Node / backend / shared libraries:
- React / UI component tests
- Use Testing Library with the existing runner:
@testing-library/reactwith Vitest or Jest
- Use Testing Library with the existing runner:
- End‑to‑end browser tests
- Prefer Playwright if installed or if starting from scratch
- Use Cypress if the repo already uses it or the user asks for it explicitly
If the repo uses a less common stack (Mocha, Ava, Node’s built‑in test runner), respect that choice and adapt.
Core testing philosophy
Follow these principles:
- Test behavior, not implementation details
- For React/UI: test what the user sees and does (DOM, events, ARIA), not internal state or private methods
- For services: test public APIs, not private helpers
- Keep tests fast and focused
- Prefer small, deterministic tests that run quickly
- Avoid unnecessary network, filesystem, or database calls unless you are explicitly writing integration tests
- Make failures obvious
- Clear naming and assertions that explain why a test failed
- Use descriptive test names following “given/when/then” style where helpful
- Minimize mocking, but use it where it makes sense
- Mock external services, network calls, and slow dependencies
- Avoid mocking your own business logic unless there’s a strong reason
Standard workflow
When asked to add or improve tests, follow this workflow:
-
Detect the existing stack
- Inspect
package.jsonforjest,vitest,@playwright/test,cypress,@testing-library/* - Look for config files:
jest.config.*,vitest.config.*,playwright.config.*,cypress.config.* - Check
test,unit, ore2escripts inpackage.json
- Inspect
-
Locate the right place for the test
- Mirror existing patterns:
- If tests live in
__tests__directories, follow that - If they use
*.test.tsor*.spec.ts, do the same
- If tests live in
- For UI: place tests near the component (e.g.
Component.test.tsx) if that’s the existing convention
- Mirror existing patterns:
-
Write the test in a TS‑friendly way
- Use
.test.ts/.test.tsx(or.spec) as per repo convention - Avoid
anyin tests when possible; use real types or minimal interfaces to keep tests robust - For async code: use
awaitwith async test functions, avoid dangling promises
- Use
-
Follow library‑specific best practices
Vitest / Jest
- Use
describe/itortestwith clear names - Prefer
vi.fn()/jest.fn()for spies and mocks - For modules: use
vi.mock()/jest.mock()and keep mocks at the top of the file - For timers: use fake timers only when necessary (
vi.useFakeTimers()/jest.useFakeTimers())
React Testing Library
- Use
render,screen, and user interactions (userEvent) - Query by role, label, text as a user would (prefer
getByRole,getByLabelText) - Avoid querying by test IDs unless there’s no good semantic alternative
Playwright / Cypress
- Use existing fixtures and helpers (e.g. authenticated sessions, base URL) instead of re‑inventing them
- Keep tests independent; don’t rely on order
- Use
data-testidor semantics consistently as locators
- Use
-
Add regression tests for reported bugs
- Reproduce the bug in a failing test first
- Only then change the implementation to make the test pass
- Name regression tests clearly (e.g.
it("does not crash when X is null (regression #123)"))
-
Running tests
- Use existing scripts, e.g.
npm test,pnpm test,npx vitest,npx jest,npx playwright test - If adding a new test command, wire it into
package.jsonscripts following existing style
- Use existing scripts, e.g.
Patterns to prefer
- One behavior per test: Don’t cram multiple unrelated assertions into a single test unless they’re part of the same scenario.
- Helper factories: Use small factory functions for building test data (
makeUser,makeOrder) instead of duplicating setup. - Explicit async handling: Always
awaitpromises; avoid passing async callbacks to APIs that don’t expect them.
Anti‑patterns to avoid
- Overuse of snapshots for complex objects or DOM – use targeted assertions instead
- Testing private methods directly
- Heavy mocking that makes tests mirror implementation wiring
- Flaky tests that depend on real time, network, or global state without control
TypeScript‑specific guidance
- Use the project’s
tsconfigfor tests when possible (tsconfig.test.jsonif present) - Avoid silencing type errors just to “get tests compiling”
- When stubbing data, create minimal typed helpers rather than using
as any
If the user asks you to generate tests, prefer fewer, high‑value tests that mirror real usage over large, mechanical test suites.
You might also like
flutter-development
aj-geddes
Build beautiful cross-platform mobile apps with Flutter and Dart. Covers widgets, state management with Provider/BLoC, navigation, API integration, and material design.
drawio-diagrams-enhanced
jgtolentino
Create professional draw.io (diagrams.net) diagrams in XML format (.drawio files) with integrated PMP/PMBOK methodologies, extensive visual asset libraries, and industry-standard professional templates. Use this skill when users ask to create flowcharts, swimlane diagrams, cross-functional flowcharts, org charts, network diagrams, UML diagrams, BPMN, project management diagrams (WBS, Gantt, PERT, RACI), risk matrices, stakeholder maps, or any other visual diagram in draw.io format. This skill includes access to custom shape libraries for icons, clipart, and professional symbols.
godot
bfollington
This skill should be used when working on Godot Engine projects. It provides specialized knowledge of Godot's file formats (.gd, .tscn, .tres), architecture patterns (component-based, signal-driven, resource-based), common pitfalls, validation tools, code templates, and CLI workflows. The `godot` command is available for running the game, validating scripts, importing resources, and exporting builds. Use this skill for tasks involving Godot game development, debugging scene/resource files, implementing game systems, or creating new Godot components.
nano-banana-pro
garg-aayush
Generate and edit images using Google's Nano Banana Pro (Gemini 3 Pro Image) API. Use when the user asks to generate, create, edit, modify, change, alter, or update images. Also use when user references an existing image file and asks to modify it in any way (e.g., "modify this image", "change the background", "replace X with Y"). Supports both text-to-image generation and image-to-image editing with configurable resolution (1K default, 2K, or 4K for high resolution). DO NOT read the image file first - use this skill directly with the --input-image parameter.
ui-ux-pro-max
nextlevelbuilder
"UI/UX design intelligence. 50 styles, 21 palettes, 50 font pairings, 20 charts, 8 stacks (React, Next.js, Vue, Svelte, SwiftUI, React Native, Flutter, Tailwind). Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, check UI/UX code. Projects: website, landing page, dashboard, admin panel, e-commerce, SaaS, portfolio, blog, mobile app, .html, .tsx, .vue, .svelte. Elements: button, modal, navbar, sidebar, card, table, form, chart. Styles: glassmorphism, claymorphism, minimalism, brutalism, neumorphism, bento grid, dark mode, responsive, skeuomorphism, flat design. Topics: color palette, accessibility, animation, layout, typography, font pairing, spacing, hover, shadow, gradient."
rust-coding-skill
UtakataKyosui
Guides Claude in writing idiomatic, efficient, well-structured Rust code using proper data modeling, traits, impl organization, macros, and build-speed best practices.
Stay ahead of the MCP ecosystem
Get weekly updates on new skills and servers.