一键导入
jest-patterns
Jest and Vitest testing patterns including describe/it blocks, expect matchers, mocking, and async test strategies for JavaScript and TypeScript.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Jest and Vitest testing patterns including describe/it blocks, expect matchers, mocking, and async test strategies for JavaScript and TypeScript.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Translate natural language image descriptions into detailed, structured DALL-E prompts with subject, style, composition, lighting, and mood specifications.
Decompose mathematical problems into sub-expressions, evaluate each one with the calculator tool, and present the full working chain. Handles arithmetic, trigonometry, logarithms, and financial formulas.
Compare two or more PDF documents by extracting targeted sections, building a structured comparison matrix, and highlighting differences with page references.
Extract structured data from web pages using browser snapshot and text tools, then process it into tables, comparisons, or summaries using Python.
Analyze endpoint latency trends using historical check data from memory. Detects slow degradation, spikes vs sustained issues, and calculates baseline deviations.
Validate API response structure and content. Detects schema drift, unexpected null values, and abnormal response sizes.
| name | jest-patterns |
| description | Jest and Vitest testing patterns including describe/it blocks, expect matchers, mocking, and async test strategies for JavaScript and TypeScript. |
| requires | {"bins":["node"]} |
Jest and Vitest testing patterns for JavaScript and TypeScript projects.
Use this skill when the project has jest.config.*, vitest.config.*,
a package.json listing jest or vitest as a dependency, or test files
matching *.test.{js,ts,tsx} or *.spec.{js,ts,tsx}.
describe blocks to group related tests by feature or function.it (or test) blocks for individual test cases -- each one should
describe a single behavior.describe blocks for sub-scenarios (e.g. describe("when input is empty", ...) inside describe("parseConfig", ...)).beforeEach / afterEach for per-test setup and teardown.beforeAll / afterAll sparingly -- only for expensive one-time
setup like database connections.toBe(value) -- strict equality (===).toEqual(value) -- deep equality for objects and arrays.toMatchObject(subset) -- partial object matching.toThrow(error?) -- verify that a function throws.toHaveBeenCalledWith(args) -- assert mock was called with specific args.toMatchSnapshot() -- snapshot testing for serializable output.toContain(item) -- array/string includes check.toHaveLength(n) -- array or string length check.jest.fn() / vi.fn() -- create a mock function with call tracking.jest.mock("module") / vi.mock("module") -- replace an entire module
with auto-mocked version.jest.spyOn(obj, "method") / vi.spyOn(obj, "method") -- spy on a
method while keeping original implementation unless overridden.mockResolvedValue(val) -- shorthand for mocking async functions that
return promises.mockImplementation(fn) -- provide a custom implementation.async/await in test functions for promise-based code..resolves / .rejects matchers:
await expect(fetchData()).resolves.toEqual(expected).await assertions on promises -- forgetting await causes silent
passes.npx jest -- run all tests.npx jest --watch -- re-run on file changes.npx jest --testPathPattern="pattern" -- filter tests by file path.npx vitest -- run vitest in watch mode.npx vitest run -- single run without watch.describe blocks with clear names.afterEach (call jest.restoreAllMocks() or
vi.restoreAllMocks()).jest.mock or msw.