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".
Install via CLI (Recommended)
clawhub install openclaw/skills/skills/anivar/jest-skillWhat This Skill Does
The Jest skill provides the OpenClaw AI agent with deep expertise in the Jest testing framework, focusing on versions 29.0.0 and above. It acts as an authoritative reference for writing robust JavaScript and TypeScript tests, ensuring developers follow modern patterns such as async/await, effective mocking strategies, and proper timer management. The skill is designed to prevent common pitfalls, such as failing to await asynchronous tests, incorrect mock restoration, or using legacy 'done' callbacks when promise-based patterns are superior.
Installation
To integrate this skill into your environment, run the following command in your terminal:
clawhub install openclaw/skills/skills/anivar/jest-skill
Use Cases
This skill is ideal for:
- Refactoring legacy test suites to conform to modern Jest 29/30 standards.
- Debugging intermittent test failures caused by improper mock clearing or race conditions in asynchronous tests.
- Generating unit test boilerplate for new TypeScript modules.
- Optimizing test execution performance for CI/CD environments by identifying redundant mocks.
- Handling complex scenarios like partial module mocking, timer manipulation, and precise float value assertions.
Example Prompts
- "Analyze this test file and tell me why my asynchronous mock isn't being called; I'm using jest.mock but the test finishes before the promise resolves."
- "Refactor these tests to remove 'done' callbacks and convert them to use modern async/await patterns compatible with Jest 30."
- "Help me setup a mock for this node module, but ensure I only mock the specific function and keep the rest of the module functionality intact using jest.requireActual."
Tips & Limitations
- Source of Truth: Always prioritize the project's codebase and the rule files provided by this skill over general LLM training data, as Jest patterns shift frequently.
- Mock Management: The skill emphasizes the use of
clearAllMocksvsresetAllMocks. Avoid manual cleanup where possible; use therestoreMocksconfiguration to handlejest.spyOnautomatically. - ESM Support: Be aware that Jest's ESM support is evolving. Use
jest.unstable_mockModulewith caution and verify your project'sbabelorts-jestconfiguration. - Integration: While this skill is powerful for Jest, it should not be used as a replacement for browser-based E2E tools like Playwright when testing complex UI interactions or cross-origin browser behaviors.
Metadata
Not sure this is the right skill?
Describe what you want to build — we'll match you to the best skill from 16,000+ options.
Find the right skillPaste this into your clawhub.json to enable this plugin.
{
"plugins": {
"official-anivar-jest-skill": {
"enabled": true,
"auto_update": true
}
}
}Tags(AI)
Flags: file-read, code-execution
Related Skills
zod-testing
Testing patterns for Zod schemas using Jest and Vitest. Covers schema correctness testing, mock data generation, error assertion patterns, integration testing with API handlers and forms, snapshot testing with z.toJSONSchema(), and property-based testing. Baseline: zod ^4.0.0. Triggers on: test files for Zod schemas, zod-schema-faker imports, mentions of "test schema", "schema test", "zod mock", "zod test", or schema testing patterns.
redux-saga-testing
Write tests for Redux Sagas using redux-saga-test-plan, runSaga, and manual generator testing. Covers expectSaga (integration), testSaga (unit), providers, partial matchers, reducer integration, error simulation, and cancellation testing. Works with Jest and Vitest. Triggers on: test files for sagas, redux-saga-test-plan imports, mentions of "test saga", "saga test", "expectSaga", "testSaga", or "redux-saga-test-plan".
zod
Zod v4 best practices, patterns, and API guidance for schema validation, parsing, error handling, and type inference in TypeScript applications. Covers safeParse, object composition, refinements, transforms, codecs, branded types, and v3→v4 migration. Baseline: zod ^4.0.0. Triggers on: zod imports, z.object, z.string, z.infer, safeParse, mentions of "zod", "schema validation", "zod v4", or "z.enum".
redux-saga
Redux-Saga best practices, patterns, and API guidance for building, testing, and debugging generator-based side-effect middleware in Redux applications. Covers effect creators, fork model, channels, testing with redux-saga-test-plan, concurrency, cancellation, and modern Redux Toolkit integration. Baseline: redux-saga 1.4.2. Triggers on: saga files, redux-saga imports, generator-based middleware, mentions of "saga", "takeEvery", "takeLatest", "fork model", or "channels".
msw
MSW (Mock Service Worker) v2 best practices, patterns, and API guidance for API mocking in JavaScript/TypeScript tests and development. Covers handler design, server setup, response construction, testing patterns, GraphQL, and v1-to-v2 migration. Baseline: msw ^2.0.0. Triggers on: msw imports, http.get, http.post, HttpResponse, setupServer, setupWorker, graphql.query, mentions of "msw", "mock service worker", "api mocking", or "msw v2".