JavaScript Testing Patterns

JavaScript Testing Patterns is a skill for Claude Code, Codex from PramodDutta/qaskills. It costs 36 tokens per session (4,436 once invoked), scanned A, original, MIT.

A guide to testing JavaScript code with Jest and Mocha, including unit, integration, asynchronous, mock, and DOM tests.

In plain words
What is it for?
Use it to create or improve JavaScript test suites, organize test files, isolate dependencies, and test browser interfaces and asynchronous code.
Why use it?
It helps you write tests that check real behavior, run reliably, and are easier to understand when something fails.

Skill for Claude CodeCodex

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.

agentmods
npx agentmods add skills/pramoddutta/qaskills/javascript-testing-patterns
Any agent
npx skills add PramodDutta/qaskills --skill javascript-testing-patterns
Clone the repo
git clone --depth 1 https://github.com/PramodDutta/qaskills

Made for: Claude Code, Codex.

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 JavaScript Testing Patterns

README.md
[![agentmods](https://agentmods.dev/badge/skills/pramoddutta/qaskills/javascript-testing-patterns.svg)](https://agentmods.dev/skills/pramoddutta/qaskills/javascript-testing-patterns)
Your own site
<a href="https://agentmods.dev/skills/pramoddutta/qaskills/javascript-testing-patterns"><img src="https://agentmods.dev/badge/skills/pramoddutta/qaskills/javascript-testing-patterns.svg" alt="Measured on agentmods" height="20"></a>
Per session 36 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 4,436 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. Scan, not verified.
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 $0.00036 $0.04436
Opus 5 $0.00018 $0.02218
Sonnet 5 $0.00007 $0.00887
Haiku 4.5 $0.00004 $0.00444

Measured yesterday against content hash 8761fa7aafe7, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

JavaScript Testing Patterns 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 yesterday.

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.js
seed-skills/javascript-testing-patterns/SKILL.md · 682 lines

How it starts

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

JavaScript Testing Patterns Skill

You are an expert JavaScript developer specializing in testing patterns and methodologies. When the user asks you to write, review, or improve JavaScript tests, follow these detailed instructions.

Core Principles

  1. Test behavior, not implementation -- Tests should verify what code does, not how it works internally.
  2. Fast feedback loops -- Unit tests should run in milliseconds.
  3. Arrange-Act-Assert -- Clear three-phase structure for every test.
  4. Deterministic tests -- Same input always produces same output.
  5. Isolated tests -- No shared state or dependencies between tests.

Project Structure

project/
  src/
    services/
      user.service.js
      user.service.test.js
    utils/
      validators.js
      validators.test.js
    components/
      Button.jsx
      Button.test.jsx
  __tests__/
    integration/
      api.test.js
    e2e/
      checkout.test.js
  __mocks__/
    axios.js
    localStorage.js
  jest.config.js

Jest Configuration

// jest.config.js
module.exports = {
  testEnvironment: 'jsdom',
  roots: ['<rootDir>/src'],
  testMatch: ['**/__tests__/**/*.js', '**/?(*.)+(spec|test).js'],
  collectCoverageFrom: [
    'src/**/*.{js,jsx}',
    '!src/**/*.test.{js,jsx}',
    '!src/**/index.js',
  ],
  coverageThresholds: {
    global: {
      branches: 80,
      functions: 80,
      lines: 80,
      statements: 80,
    },
  },
  setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
  moduleNameMapper: {
    '^@/(.*)$': '<rootDir>/src/$1',
    '\\.(css|less|scss|sass)$': 'identity-obj-proxy',
  },
  transform: {
    '^.+\\.jsx?$': 'babel-jest',
  },
  clearMocks: true,
  restoreMocks: true,
};

Basic Testing Patterns

1. Testing Pure Functions

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

export function calculateTotal(items) {
  return items.reduce((sum, item) => sum + item.price * item.quantity, 0);
}

export function formatCurrency(amount, currency = 'USD') {
  return new Intl.NumberFormat('en-US', {
    style: 'currency',
    currency,
  }).format(amount);
}

Read the full file on GitHub · 682 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. yesterday First seen · 682 lines · 36 tokens per session scan A 8761fa7aafe7

Subscribe to this mod's changes

JavaScript Testing Patterns is a skill published in the GitHub repository PramodDutta/qaskills (214 stars, last pushed 5d ago), licensed MIT. It adds 36 tokens to every session and 4,436 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-09-03.