Comprehensive testing strategies for JavaScript/TypeScript using Jest, Vitest, and Testing Library.
Works with
Covers unit testing, integration testing, and component testing with patterns for pure functions, classes, async code, and React hooks
Includes mocking strategies: module mocking, dependency injection, and spying on functions for isolated test execution
Provides API and database integration test examples with real request/response handling and transaction cleanup
Supports snapshot t
AI-first code editor with Composer
Before installing skills in Cursor, ensure your development environment meets these requirements:
node --versionjavascript-testing-patternsExecute the skills CLI command in your project's root directory to begin installation:
Fetches javascript-testing-patterns from wshobson/agents and configures it for Cursor.
The CLI shows a list of agents. Use arrow keys and space to select Cursor:
Confirm successful installation by checking the skill directory location:
Restart Cursor to activate javascript-testing-patterns. Access via /javascript-testing-patterns in your agent's command palette.
We perform automated surface-level scans (Gen AI Scanner, Socket, Snyk) during installation. These checks detect common vulnerabilities but do not guarantee complete security. Always review skill source code and verify the publisher's reputation before production use.
Skills execute code in your environment. Always review source, verify the publisher, and test in isolation before production.
Submit your Claude Code skill and start earning
Automate repetitive workflows and reduce manual effort
Example
Generate reports, summarize documents, draft communications
Save 3-5 hours per week on routine tasks
Learn new skills, understand complex topics, get expert guidance
Example
Explain concepts, provide examples, suggest learning resources
Accelerate learning and skill development by 2x
Enhance output quality through reviews, suggestions, and refinements
Example
Review drafts, suggest improvements, catch errors
Improve work quality by 30-40% with less effort
0
total installs
0
this week
33.1K
GitHub stars
0
upvotes
Run in your terminal
0
installs
0
this week
33.1K
stars
Comprehensive guide for implementing robust testing strategies in JavaScript/TypeScript applications using modern testing frameworks and best practices.
Setup:
// jest.config.ts
import type { Config } from "jest";
const config: Config = {
preset: "ts-jest",
testEnvironment: "node",
roots: ["<rootDir>/src"],
testMatch: ["**/__tests__/**/*.ts", "**/?(*.)+(spec|test).ts"],
collectCoverageFrom: [
"src/**/*.ts",
"!src/**/*.d.ts",
"!src/**/*.interface.ts",
],
coverageThreshold: {
global: {
branches: 80,
functions: 80,
lines: 80,
statements: 80,
},
},
setupFilesAfterEnv: ["<rootDir>/src/test/setup.ts"],
};
export default config;
Setup:
// vitest.config.ts
import { defineConfig } from "vitest/config";
export default defineConfig({
test: {
globals: true,
environment: "node",
coverage: {
provider: "v8",
reporter: ["text", "json", "html"],
exclude: ["**/*.d.ts", "**/*.config.ts", "**/dist/**"],
},
setupFiles: ["./src/test/setup.ts"],
},
});
// utils/calculator.ts
export function add(a: number, b: number): number {
return a + b;
}
export function divide(a: number, b: number): number {
if (b === 0) {
throw new Error("Division by zero");
}
return a / b;
}
// utils/calculator.test.ts
import { describe, it, expect } from "vitest";
import { add, divide } from "./calculator";
describe("Calculator", () => {
describe("add", () => {
it("should add two positive numbers", () => {
expect(add(2, 3)).toBe(5);
});
it("should add negative numbers", () => {
expect(add(-2, -3)).toBe(-5);
});
it("should handle zero", () => {
expect(add(0, 5)).toBe(5);
expect(add(5, 0)).toBe(5);
});
});
describe("divide", () => {
it("should divide two numbers", () => {
expect(divide(10, 2)).toBe(5);
});
it("should handle decimal results", () => {
expect(divide(5, 2)).toBe(2.5);
});
it("should throw error when dividing by zero", () => {
expect(() => divide(10, 0)).toThrow("Division by zero");
});
});
});
// services/user.service.ts
export class UserService {
private users: Map<string, User> = new Map();
create(user: User): User {
if (this.users.has(user.id)) {
throw new Error("User already exists");
}
this.users.set(user.id, user);
return user;
}
findById(id: string): User | undefined {
Implementation Guide
Prerequisites
- ›Claude Desktop or compatible AI client with skill support
- ›Clear understanding of task or problem to solve
- ›Willingness to iterate and refine outputs
Time Estimate
15-45 minutes depending on use case complexity
Steps
- 1Install skill using provided installation command
- 2Test with simple use case relevant to your work
- 3Evaluate output quality and relevance
- 4Iterate on prompts to improve results
- 5Integrate into regular workflow if valuable
Common Pitfalls
- ⚠Expecting perfect results without iteration
- ⚠Not providing enough context in prompts
- ⚠Using skill for tasks outside its intended scope
- ⚠Accepting outputs without review and validation
Best Practices
✓ Do
- +Start with clear, specific prompts
- +Provide relevant context and constraints
- +Review and refine all outputs before using
- +Iterate to improve output quality
- +Document successful prompt patterns
✗ Don't
- −Don't use without understanding skill limitations
- −Don't skip validation of outputs
- −Don't share sensitive information in prompts
- −Don't expect skill to replace human judgment
💡 Pro Tips
- ★Be specific about desired format and style
- ★Ask for multiple options to choose from
- ★Request explanations to understand reasoning
- ★Combine AI efficiency with human expertise
When to Use This
✓ Use when
Use when skill capabilities match your task, clear ROI on time saved, and you can validate outputs. Best for repetitive tasks, learning, and quality improvement.
✗ Avoid when
Avoid when task requires deep expertise you can't validate, involves sensitive decisions, or when learning process is more valuable than speed of completion.
Learning Path
- 1Familiarize yourself with skill capabilities and limitations
- 2Start with low-risk, non-critical tasks
- 3Progress to more complex and valuable use cases
- 4Build expertise through regular use and experimentation
Related Skills
python-code-style
10wshobson/agents
Backendsame repogolang-testing
9samber/cc-skills-golang
Backendtag: testingtailwind-css-patterns
21giuseppe-trisciuoglio/developer-kit
Frontendtag: patternstypescript-best-practices
163jwynia/agent-skills
Backendsame categoryfastapi-python
73mindrally/skills
Backendsame categorygoogle-search-console
53kostja94/marketing-skills
Backendsame categoryReviews
4.6★★★★★30 reviews- MMeera Martin★★★★★Dec 28, 2024
Useful defaults in javascript-testing-patterns — fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.
- AArya Agarwal★★★★★Dec 20, 2024
I recommend javascript-testing-patterns for anyone iterating fast on agent tooling; clear intent and a small, reviewable surface area.
- RRahul Santra★★★★★Nov 19, 2024
Solid pick for teams standardizing on skills: javascript-testing-patterns is focused, and the summary matches what you get after install.
- HHana Zhang★★★★★Nov 19, 2024
javascript-testing-patterns is among the better-maintained entries we tried; worth keeping pinned for repeat workflows.
- PPratham Ware★★★★★Oct 10, 2024
I recommend javascript-testing-patterns for anyone iterating fast on agent tooling; clear intent and a small, reviewable surface area.
- MMeera Abbas★★★★★Oct 10, 2024
javascript-testing-patterns reduced setup friction for our internal harness; good balance of opinion and flexibility.
- YYash Thakker★★★★★Sep 25, 2024
javascript-testing-patterns reduced setup friction for our internal harness; good balance of opinion and flexibility.
- SSophia Choi★★★★★Sep 21, 2024
I recommend javascript-testing-patterns for anyone iterating fast on agent tooling; clear intent and a small, reviewable surface area.
- NNaina Garcia★★★★★Sep 17, 2024
We added javascript-testing-patterns from the explainx registry; install was straightforward and the SKILL.md answered most questions upfront.
- AAma Dixit★★★★★Sep 13, 2024
Useful defaults in javascript-testing-patterns — fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.
showing 1-10 of 30
1 / 3Discussion
Comments — not star reviews- No comments yet — start the thread.