jest-unit

jest-unit is a skill for Claude Code from PramodDutta/qaskills. It costs 32 tokens per session (3,782 once invoked), scanned A, original, MIT.

A guide to unit testing JavaScript and TypeScript code with Jest, a test runner. Unit tests check small pieces of code separately, often replacing databases or network services with controlled substitutes.

In plain words
What is it for?
It helps write tests with mocks, spies, snapshots, asynchronous operations, code-coverage checks, and custom matchers, using a clear setup, execution, and verification structure.
Why use it?
It makes tests focused, repeatable, and quick, while checking what the code does rather than depending on external systems or its internal implementation.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin. Also seen: positional $N argument.

Part of the qa-essentials plugin — 10 skills shipped together

Good fit It helps write tests with mocks, spies, snapshots, asynchronous operations, code-coverage checks, and custom matchers, using a clear setup, execution, and verification structure.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/pramoddutta/qaskills/jest-unit
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 PramodDutta/qaskills --skill jest-unit
Clone the repo
git clone --depth 1 https://github.com/PramodDutta/qaskills

Made for: Claude Code.

Or install qa-essentials, the plugin that ships this one along with the rest of its 10 skills.

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-unit

README.md
[![agentmods](https://agentmods.dev/badge/skills/pramoddutta/qaskills/jest-unit.svg)](https://agentmods.dev/skills/pramoddutta/qaskills/jest-unit)
Your own site
<a href="https://agentmods.dev/skills/pramoddutta/qaskills/jest-unit"><img src="https://agentmods.dev/badge/skills/pramoddutta/qaskills/jest-unit.svg" alt="Measured on agentmods" height="20"></a>
Per session 32 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,782 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector warn 7 Sept 2026
SkillSpector: 7 findings, up to medium

These are SkillSpector’s own severities. On a checked sample its high-severity flags on skills were ~96% false positives — a documented command, a public API, a “never do X” rule — so we show them as a caution to read, not a verdict. Why →

  • medium MCP Rug Pull · line 559
    npx commands without a version suffix (e.g. @1.0.0) create a rug-pull risk if the upstream server is compromised and publishes a malicious update.
    Fix: Pin the version: npx @scope/[email protected]
  • medium MCP Rug Pull · line 562
    npx commands without a version suffix (e.g. @1.0.0) create a rug-pull risk if the upstream server is compromised and publishes a malicious update.
    Fix: Pin the version: npx @scope/[email protected]
  • medium MCP Rug Pull · line 565
    npx commands without a version suffix (e.g. @1.0.0) create a rug-pull risk if the upstream server is compromised and publishes a malicious update.
    Fix: Pin the version: npx @scope/[email protected]
  • medium MCP Rug Pull · line 568
    npx commands without a version suffix (e.g. @1.0.0) create a rug-pull risk if the upstream server is compromised and publishes a malicious update.
    Fix: Pin the version: npx @scope/[email protected]
  • medium MCP Rug Pull · line 571
    npx commands without a version suffix (e.g. @1.0.0) create a rug-pull risk if the upstream server is compromised and publishes a malicious update.
    Fix: Pin the version: npx @scope/[email protected]
  • medium MCP Rug Pull · line 574
    npx commands without a version suffix (e.g. @1.0.0) create a rug-pull risk if the upstream server is compromised and publishes a malicious update.
    Fix: Pin the version: npx @scope/[email protected]
  • medium MCP Rug Pull · line 577
    npx commands without a version suffix (e.g. @1.0.0) create a rug-pull risk if the upstream server is compromised and publishes a malicious update.
    Fix: Pin the version: npx @scope/[email protected]
How audits are shown
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.00032 $0.03782
Opus 5 $0.00016 $0.01891
Sonnet 5 $0.00006 $0.00756
Haiku 4.5 $0.00003 $0.00378

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

Security

Grade A, and why

jest-unit scanned grade A with 1 finding 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 8d 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.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

axios.ts
packs/qa-essentials/skills/jest-unit/SKILL.md · 579 lines

How it starts

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

Jest Unit Testing Skill

You are an expert software engineer specializing in unit testing with Jest. When the user asks you to write, review, or debug Jest unit tests, follow these detailed instructions.

Core Principles

  1. Test behavior, not implementation -- Tests should verify what code does, not how it does it.
  2. One assertion focus per test -- Each test should verify a single logical concept.
  3. Arrange-Act-Assert -- Structure every test into setup, execution, and verification.
  4. Fast and isolated -- Unit tests must run in milliseconds and have no external dependencies.
  5. Descriptive names -- Test names should read as specifications of the code's behavior.

Project Structure

src/
  services/
    user.service.ts
    user.service.test.ts
    order.service.ts
    order.service.test.ts
  utils/
    validators.ts
    validators.test.ts
    formatters.ts
    formatters.test.ts
  models/
    user.model.ts
  __mocks__/
    axios.ts
    database.ts
  __tests__/
    integration/
      user-order.test.ts
jest.config.ts

Configuration

// jest.config.ts
import type { Config } from 'jest';

const config: Config = {
  preset: 'ts-jest',
  testEnvironment: 'node',
  roots: ['<rootDir>/src'],
  testMatch: ['**/*.test.ts', '**/*.spec.ts'],
  collectCoverageFrom: [
    'src/**/*.ts',
    '!src/**/*.d.ts',
    '!src/**/*.test.ts',
    '!src/**/index.ts',
  ],
  coverageThresholds: {
    global: {
      branches: 80,
      functions: 80,
      lines: 80,
      statements: 80,
    },
  },
  coverageReporters: ['text', 'lcov', 'json-summary'],
  moduleNameMapper: {
    '^@/(.*)$': '<rootDir>/src/$1',
  },
  setupFilesAfterSetup: ['<rootDir>/jest.setup.ts'],
  clearMocks: true,
  restoreMocks: true,
};

export default config;

Writing Tests

Basic Test Structure

// validators.ts
export function isValidEmail(email: string): boolean {
  const regex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
  return regex.test(email);
}

export function isStrongPassword(password: string): boolean {
  return (
    password.length >= 8 &&
    /[A-Z]/.test(password) &&
    /[a-z]/.test(password) &&
    /[0-9]/.test(password) &&
    /[!@#$%^&*]/.test(password)
  );
}

Read the full file on GitHub · 579 lines

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. 8d ago First seen · 579 lines · 32 tokens per session scan A e562a24efdec

Subscribe to this mod's changes

jest-unit is a skill published in the GitHub repository PramodDutta/qaskills (218 stars, last pushed 8d ago), licensed MIT. It adds 32 tokens to every session and 3,782 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.