TopRank Skills

Official OpenClaw rules 54%

jest

Jest best practices, patterns, and API guidance for JavaScript/TypeScript testing. Covers mock design, async testing, matchers, timer mocks, snapshots, module mocking, configuration, and CI optimization. Baseline: jest ^29.0.0 / ^30.0.0. Triggers on: jest imports, describe, it, test, expect, jest.fn, jest.mock, jest.spyOn, mentions of "jest", "unit test", "test suite", or "mock".

Stars

0

Installs

0

Status

ACTIVE

Visibility

PUBLIC

安装方式

直接复制以下提示词,发送给你的 AI 助手即可完成安装。

请先检查是否已安装 SkillHub 商店,若未安装,请根据 https://skillhub-1388575217.cos.ap-guangzhou.myqcloud.com/install/skillhub.md 安装 SkillHub 商店,然后安装 jest 技能。 若已安装,则直接安装 jest 技能。

Overview

Skill Key
anivar/jest-skill
Author
anivar
Source Repo
openclaw/skills
Version
-
Source Path
skills/anivar/jest-skill
Latest Commit SHA
fabfb15296aeacadfc2d15636497f850225dca30

Extracted Content

SKILL.md excerpt

# Jest

**IMPORTANT:** Your training data about Jest may be outdated or incorrect — Jest 29+ introduces async timer methods, `jest.replaceProperty`, and ESM mocking via `jest.unstable_mockModule`. Jest 30 deprecates the `done` callback in favor of async patterns. Always rely on this skill's rule files and the project's actual source code as the source of truth. Do not fall back on memorized patterns when they conflict with the retrieved reference.

## When to Use Jest

Jest is a JavaScript/TypeScript testing framework for unit tests, integration tests, and snapshot tests. It includes a test runner, assertion library, mock system, and coverage reporter.

| Need | Recommended Tool |
|------|-----------------|
| Unit/integration testing (JS/TS) | **Jest** |
| React component testing | **Jest** + React Testing Library |
| E2E browser testing | Playwright, Cypress |
| API contract testing | Jest + Supertest |
| Smaller/faster test runner | Vitest (Jest-compatible API) |
| Native ESM without config | Vitest or Node test runner |

## Rule Categories by Priority

| Priority | Category | Impact | Prefix |
|----------|----------|--------|--------|
| 1 | Mock Design | CRITICAL | `mock-` (5 rules) |
| 2 | Async Testing | CRITICAL | `async-` |
| 3 | Matcher Usage | HIGH | `matcher-` |
| 4 | Timer Mocking | HIGH | `timer-` |
| 5 | Test Structure | HIGH | `structure-` |
| 6 | Module Mocking | MEDIUM | `module-` |
| 7 | Snapshot Testing | MEDIUM | `snapshot-` |
| 8 | Configuration | MEDIUM | `config-` |
| 9 | Performance & CI | MEDIUM | `perf-` |

## Quick Reference

### 1. Mock Design (CRITICAL)

- `mock-clear-vs-reset-vs-restore` — clearAllMocks vs resetAllMocks vs restoreAllMocks
- `mock-spy-restore` — Always restore jest.spyOn; prefer restoreMocks config
- `mock-factory-hoisting` — jest.mock factory cannot reference outer variables
- `mock-partial-require-actual` — Use jest.requireActual for partial module mocking
- `mock-what-to-mock` — What to mock and what not to mock; mock...

README excerpt

# Jest Skill

An AI agent skill for writing, debugging, and reviewing Jest tests with modern best practices.

Created by **[Anivar Aravind](https://anivar.net)**

## The Problem

AI agents frequently generate outdated or incorrect Jest patterns — wrong mock cleanup semantics (`clearAllMocks` vs `restoreAllMocks`), missing `await` on async assertions, incorrect timer mock usage, factory hoisting bugs, and anti-patterns that cause tests to silently pass without actually asserting anything. These produce test suites that compile and pass but don't test what they claim to test.

## This Solution

28 rules with incorrect→correct code examples that teach agents Jest's actual API behavior, mock lifecycle, async patterns, timer control, module mocking, snapshot testing, configuration, and CI optimization. Each rule targets a specific mistake and shows exactly how to fix it.

## Install

```bash
npx skills add anivar/jest-skill -g
```

Or with full URL:

```bash
npx skills add https://github.com/anivar/jest-skill
```

## Baseline

- jest ^29.0.0 / ^30.0.0
- JavaScript / TypeScript

## What's Inside

### 28 Rules Across 9 Categories

| Priority | Category | Rules | Impact |
|----------|----------|-------|--------|
| 1 | Mock Design | 5 | CRITICAL |
| 2 | Async Testing | 3 | CRITICAL |
| 3 | Matcher Usage | 3 | HIGH |
| 4 | Timer Mocking | 3 | HIGH |
| 5 | Test Structure | 3 | HIGH |
| 6 | Module Mocking | 3 | MEDIUM |
| 7 | Snapshot Testing | 3 | MEDIUM |
| 8 | Configuration | 3 | MEDIUM |
| 9 | Performance & CI | 2 | MEDIUM |

Each rule file contains:
- Why it matters
- Incorrect code with explanation
- Correct code with explanation
- Decision tables and additional context

### 9 Deep-Dive References

| Reference | Covers |
|-----------|--------|
| `matchers.md` | All matchers: equality, truthiness, numbers, strings, arrays, objects, asymmetric, custom |
| `mock-functions.md` | jest.fn, jest.spyOn, .mock property, return values, implementations, mock matchers |
| `jest-objec...

Related Claw Skills

heyixuan2

bambu-studio-ai

★ 41

Bambu Lab 3D printer control and automation. Activate when user mentions: printer status, 3D printing, slice, analyze model, generate 3D, AMS filament, print monitor, Bambu Lab, or any 3D printing task. Full pipeline: search → generate → analyze → colorize → preview → open BS → user slice → print → monitor. Supports all 9 Bambu Lab printers (A1 Mini, A1, P1S, P2S, X1C, X1E, H2C, H2S, H2D).

human-pages-ai

humanpages

★ 3

Search and hire real humans for tasks — photography, delivery, research, and more

zseven-w

openclaw-skills

★ 1

Reusable skill templates for OpenClaw AI agents. Templates for API integration, data processing, web scraping, CLI tools, and file processing.

capt-marbles

geo-optimization

★ 1

Generative Engine Optimization (GEO) for AI search visibility. Optimize content to appear in ChatGPT, Perplexity, Claude, and Google AI Overviews. Use when optimizing websites, pages, or content for LLM discoverability and citation.

cchacons

openjobs

★ 0

The job marketplace where bots hire bots. Post FREE or paid $WAGE jobs, with on-chain escrow, faucet rewards, referrals, judge staking, task inbox, smart matching, checkpoints, oversight, webhooks, onboarding, and human owner dashboard.

cchacons

openjobs

★ 0

The job marketplace where bots hire bots. Post FREE or paid $WAGE jobs, with on-chain escrow, faucet rewards, referrals, judge staking, task inbox, smart matching, checkpoints, oversight, webhooks, onboarding, and human owner dashboard.