/quality-tools:advanced-js-mocking-patternsfrom quality-tools
Advanced mocking patterns for Jest and Vitest including module mocking, spies, and fake timers. PROACTIVELY activate for: (1) Module mocking, (2) Partial mocking with spies, (3) Mock lifecycle management, (4) Fake timers for time-dependent code, (5) Complex mock implementations. Triggers: "jest.mock", "vi.mock", "spyOn", "fakeTimers", "mockImplementation", "mockReturnValue", "mock lifecycle"
Ships in quality-tools. 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.
Keywords: jest.mock, vi.mock, spyOn, fakeTimers, mockImplementation
File Patterns: *.test.ts, *.spec.js
Modes: testing_frontend, testing_backend
// Mock entire module
jest.mock('axios');
import axios from 'axios';
test('fetches data', async () => {
(axios.get as jest.Mock).mockResolvedValue({ data: { id: 1 } });
const result = await fetchUser(1);
expect(result).toEqual({ id: 1 });
});
const obj = {
method1: () => 'original',
method2: () => 'original'
};
const spy = jest.spyOn(obj, 'method1');
spy.mockReturnValue('mocked');
obj.method1(); // 'mocked'
obj.method2(); // 'original' (not mocked)
expect(spy).toHaveBeenCalled();
beforeEach(() => {
jest.clearAllMocks(); // Reset call counts
});
afterEach(() => {
jest.restoreAllMocks(); // Restore original implementations
});
jest.useFakeTimers();
test('debounce function', () => {
const callback = jest.fn();
const debounced = debounce(callback, 1000);
debounced();
debounced();
debounced();
jest.advanceTimersByTime(1000);
expect(callback).toHaveBeenCalledTimes(1); // Only last call
});
const mock = jest.fn()
.mockImplementationOnce(() => 'first')
.mockImplementationOnce(() => 'second')
.mockImplementation(() => 'default');
mock(); // 'first'
mock(); // 'second'
mock(); // 'default'
What SKILL.md sets; muted values are Claude Code's defaults
7 skills in this plugin
/python-code-review-and-lintingRuff linting rules, security patterns, mypy type checking, and Python code review best practices. PROACTIVELY activate for: (1) Setting up Ruff linting, (2) Fixing security vulnerabilities, (3) Resolving mypy type errors, (4) Code review for anti-patterns, (5) Python best practices enforcement. Triggers: "ruff", "lint", "refactor", "security", "anti-pattern", "python review", "mypy", "type error"
/python-testing-patternsPytest fixtures, parametrization, mocking, and test organization patterns. PROACTIVELY activate for: (1) Writing pytest test suites, (2) Creating fixtures, (3) Implementing parametrized tests, (4) Mocking external dependencies, (5) Organizing test directories. Triggers: "pytest", "fixture", "parametrize", "mock", "python test", "unittest", "conftest"
/qa-strategy-and-metricsTesting pyramid, quality metrics, and technical debt management strategies. PROACTIVELY activate for: (1) Designing testing strategy, (2) Evaluating code quality metrics, (3) Managing technical debt, (4) Analyzing test coverage approaches, (5) Calculating complexity. Triggers: "testing strategy", "testing pyramid", "quality metrics", "technical debt", "cyclomatic complexity", "maintainability", "coverage principles"
/test-coverage-analysisTest coverage analysis, gap identification, and coverage configuration for Python and JavaScript. PROACTIVELY activate for: (1) Analyzing coverage reports, (2) Identifying critical coverage gaps, (3) Configuring coverage tools, (4) Setting up CI/CD coverage checks, (5) Branch coverage analysis. Triggers: "coverage", "uncovered", "pytest-cov", "istanbul", "c8", "coverage report", "coverage gap"
/typescript-code-review-and-lintingESLint configuration, TypeScript type safety rules, and React-specific linting patterns. PROACTIVELY activate for: (1) Setting up ESLint for TypeScript, (2) Fixing type safety issues, (3) React-specific linting rules, (4) Resolving TypeScript compiler errors, (5) Code review for anti-patterns. Triggers: "eslint", "typescript", "type checking", "refactor", "ts review", "no-explicit-any", "ts-ignore"
/typescript-component-testingJest, Vitest, and React Testing Library patterns for component testing. PROACTIVELY activate for: (1) Writing React component tests, (2) Using Testing Library queries, (3) Testing user interactions, (4) Async component testing, (5) Accessibility-focused testing. Triggers: "jest", "vitest", "testing-library", "react test", "component test", "render", "screen", "userEvent"
npx claudepluginhub agentient/vibekit --plugin quality-toolsOther plugins' skills for the same job