unit-tests

unit-tests is a skill for Claude Code, Codex from Khan/wonder-blocks. It costs 34 tokens per session (3,941 once invoked), scanned A, original, MIT.

A set of guidelines for writing unit tests for React user interfaces with Jest and React Testing Library. Unit tests check small parts of a program in isolation.

In plain words
What is it for?
Use it when creating or editing TypeScript tests for React components and business logic, including arranging setup, performing an action, and checking the result.
Why use it?
It helps keep tests organized and directs attention to meaningful behavior and the real cause of failures.

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/khan/wonder-blocks/unit-tests
Any agent
npx skills add Khan/wonder-blocks --skill unit-tests
Clone the repo
git clone --depth 1 https://github.com/Khan/wonder-blocks

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

README.md
[![agentmods](https://agentmods.dev/badge/skills/khan/wonder-blocks/unit-tests.svg)](https://agentmods.dev/skills/khan/wonder-blocks/unit-tests)
Your own site
<a href="https://agentmods.dev/skills/khan/wonder-blocks/unit-tests"><img src="https://agentmods.dev/badge/skills/khan/wonder-blocks/unit-tests.svg" alt="Measured on agentmods" height="20"></a>
Per session 34 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,941 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. 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.00034 $0.03941
Opus 5 $0.00017 $0.01971
Sonnet 5 $0.00007 $0.00788
Haiku 4.5 $0.00003 $0.00394

Measured 5d ago against content hash 3e75ef5ee47b, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

unit-tests 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 5d 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.

.agents/skills/unit-tests/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 Best Practices

This guide covers testing patterns and best practices for Jest and React Testing Library in the Wonder Blocks codebase.

Core Testing Principles

⚠️ Critical Setup Rules

Test Workflow Priority:

  • ALWAYS fix failing tests BEFORE fixing linting errors
  • Focus on underlying errors, not Unhandled console.error call messages
  • ⚠️ When tests fail with Unhandled console.error call, look for the root cause error (e.g., ReferenceError: window is not defined)
  • ⚠️ The console.error messages are symptoms, not the actual problem - fix the underlying issue

File Structure:

  • ✅ Name test files with .test.ts or .test.tsx suffix
  • ✅ Place in __tests__/ directory OR colocate with source files (follow local conventions)

Test Framework Setup:

  • ✅ Additional matchers from React Testing Library (RTL) and jest-extended are available
  • ✅ Use describe/it pattern for test organization
  • ✅ Use globalThis prefix when accessing global objects
  • Prioritize testing non-trivial business logic over trivial implementations

Arrange-Act-Assert Pattern

⚠️ ALWAYS use this three-section structure:

describe("Calculator", () => {
    it("should add two numbers correctly", () => {
        // Arrange
        const a = 5;
        const b = 3;

        // Act
        const result = add(a, b);

        // Assert
        expect(result).toBe(8);
    });
});

Rules:

  • ALWAYS divide tests into Arrange, Act, Assert sections with comments
  • Each section gets exactly one comment label (// Arrange, // Act, // Assert) — no additional comments within a section
  • NEVER combine sections (e.g., don't write // Act & Assert)
  • NEVER use multiple Act or Assert sections in a single test (split into separate tests instead)
  • NEVER remove Arrange, Act, Assert comments

Exception - Testing Thrown Errors:

When testing errors, use an underTest variable in the Act section:

Read the full file on GitHub · 486 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. 5d ago First seen · 486 lines · 34 tokens per session scan A 3e75ef5ee47b

Subscribe to this mod's changes

unit-tests is a skill published in the GitHub repository Khan/wonder-blocks (163 stars, last pushed yesterday), licensed MIT. It adds 34 tokens to every session and 3,941 once invoked, about $0.0002 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-30.

Related

Other skills, from other repositories

material-ui-nextjs

Integrates Material UI with Next.js App and Pages routers using @mui/material-nextjs, Emotion cache providers, next/font, CSS layers with Tailwind/CSS Modules, Link component prop patterns, CSS theme variables SSR notes, and App Router useSearchParams + Suspense. Use when setting up or debugging MUI in a Next.js app.

mui/material-ui · 76 tokens

material-ui-styling

Chooses the right Material UI styling approach (sx, styled, theme overrides, global CSS) from official MUI guidance. Use when styling @mui/material components, customizing themes, overriding slots, or comparing sx vs styled.

mui/material-ui · 52 tokens

material-ui-tailwind

Integrates Material UI with Tailwind CSS v4 using cascade layers (enableCssLayer, @layer order) and documents Tailwind v3 interoperability (preflight, important, injectFirst, portals). Use when combining MUI with Tailwind utilities, slotProps className, or theme token bridges.

mui/material-ui · 67 tokens

material-ui-theming

Guides Material UI theming and design tokens (createTheme, ThemeProvider, palette, colorSchemes, cssVariables, theme.vars, dark mode, TypeScript augmentation). Use when building or extending a theme, toggling light/dark, or aligning tokens across an app.

mui/material-ui · 63 tokens

tamagui

Universal React UI framework for web and native. Use when building cross-platform apps with Tamagui, creating styled components with styled(), configuring design tokens/themes, using Tamagui UI components, or working with animations. Triggers: "tamagui", "styled()", "$token", "XStack/YStack", "useTheme", "@tamagui/"…

tamagui/tamagui · 90 tokens

beui

Pick and install beUI (@beui) animated React components from the shadcn registry. Use when building motion UI, agent/chat interfaces, toasts, docks, bottom sheets, drawers, popovers, sliders, loaders, 404 pages, or any beui.dev component. Maps user intent to exact @beui install slugs instead of inventing custom…

starc007/ui-components · 78 tokens