jest-testing-conventions

jest-testing-conventions is a skill for Claude Code from quatico-solutions/agent-skills. It costs 76 tokens per session (2,917 once invoked), scanned A, original, MIT.

A set of conventions for writing unit tests with Jest, a JavaScript testing tool. It explains how to name test variables, structure tests, use test doubles, and control mocked modules and timers.

In plain words
What is it for?
Writing Jest tests with `jest.fn`, `jest.spyOn`, and `jest.mock`, arranging tests in clear steps, and correctly clearing, resetting, or restoring mocks.
Why use it?
It makes Jest tests easier to read and reduces mistakes when replacing functions or modules during a test. It also keeps the testing mechanics separate from TDD, the practice of writing tests as part of a red-green-refactor cycle.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the quatico-skills plugin — 18 skills shipped together

Good fit Writing Jest tests with jest.fn, jest.spyOn, and jest.mock, arranging tests in clear steps, and correctly clearing, resetting, or restoring mocks.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/quatico-solutions/agent-skills/jest-testing-conventions
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add quatico-solutions/agent-skills --skill jest-testing-conventions
Clone the repo
git clone --depth 1 https://github.com/quatico-solutions/agent-skills

Made for: Claude Code.

Or install quatico-skills, the plugin that ships this one along with the rest of its 18 skills.

Its marketplace also offers this one on its own, as the plugin jest-testing-conventions/plugin install jest-testing-conventions after adding the marketplace above.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for jest-testing-conventions

README.md
[![agentmods](https://agentmods.dev/badge/skills/quatico-solutions/agent-skills/jest-testing-conventions/github.svg)](https://agentmods.dev/skills/quatico-solutions/agent-skills/jest-testing-conventions)
Your own site
<a href="https://agentmods.dev/skills/quatico-solutions/agent-skills/jest-testing-conventions"><img src="https://agentmods.dev/badge/skills/quatico-solutions/agent-skills/jest-testing-conventions/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for jest-testing-conventions

Your own site · 80×15
<a href="https://agentmods.dev/skills/quatico-solutions/agent-skills/jest-testing-conventions"><img src="https://agentmods.dev/badge/skills/quatico-solutions/agent-skills/jest-testing-conventions.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 76 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,917 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00076 $0.02917
Opus 5 $0.00038 $0.01458
Sonnet 5 $0.00015 $0.00583
Haiku 4.5 $0.00008 $0.00292

Measured 10d ago against content hash 90125c388084, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-10, from the pricing page.

Security

Grade A, and why

jest-testing-conventions scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 10d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/jest-testing-conventions/SKILL.md · 486 lines

How it starts

The opening of the file, as written. The whole thing — 486 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Jest Testing Conventions

TDD Flow

Red-Green-Refactor, including the stopping rule and verification budget, lives in the test-driven-development skill. This skill covers the Jest mechanics only.

Overview

Master three functions: jest.fn(), jest.spyOn(), jest.mock().

Core principle: Mocks are necessary evil. Prefer real code. Use mocks only when unavoidable.

Naming Conventions

Variable Naming

Name Purpose Example
testObj Object under test const testObj = new OrderService()
target Function under test const target = jest.fn()
target* Specific mock target targetAdd, targetFetch
mock* Mock implementation mockUserService, mockResponse
actual Result from code const actual = testObj.calculate()
expected Expected value const expected = 42

Test Structure

describe("OrderService", () => {
    describe("calculateTotal", () => {
        it("returns sum of item prices", () => {
            // Arrange
            const testObj = new OrderService();
            const mockItems = [{ price: 10 }, { price: 20 }];
            const expected = 30;

            // Act
            const actual = testObj.calculateTotal(mockItems);

            // Assert
            expect(actual).toBe(expected);
        });
    });
});

The Three Core Functions

jest.fn() - Stub a Function

Creates a mock function that can be observed and configured.

// Basic stub
const target = jest.fn();
target("foo");
expect(target).toHaveBeenCalledWith("foo");

// With return value
const target = jest.fn().mockReturnValue("bar");
expect(target()).toBe("bar");

// With implementation
const target = jest.fn((x) => x * 2);
expect(target(5)).toBe(10);

// With promise resolution
const target = jest.fn().mockResolvedValue({ data: "result" });
await expect(target()).resolves.toEqual({ data: "result" });

// One-time implementation
const target = jest.fn()
    .mockReturnValueOnce("first")
    .mockReturnValueOnce("second")
    .mockReturnValue("default");

Read the full file on GitHub · 486 lines

Files

What ships with it

3 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 10d ago First seen · 486 lines · 76 tokens per session scan A 90125c388084

Subscribe to this mod's changes

jest-testing-conventions is a skill published in the GitHub repository quatico-solutions/agent-skills (2 stars, last pushed 6d ago), licensed MIT. It adds 76 tokens to every session and 2,917 once invoked, about $0.0004 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.