Skip to content
Skillv1.0.0

jest-expert

Expert in Jest unit testing framework, mocks, snapshots, coverage reports, watch mode, and custom matchers. Use when the user mentions testing, unit testing, JavaScript, QA, mocking, or snapshots, or

by personamanagmentlayer(0) 0 installs
Free
Sign in to install

Free account. Installing gives you the manifest plus copy-paste snippets.

See reviews

About

Imported from personamanagmentlayer/pcl (stdlib/qa/jest-expert/SKILL.md). Install upstream with npx skills add personamanagmentlayer/pcl --skill jest-expert. Copyright stays with the author.

Jest Expert

Core Concepts

Jest Framework

  • Zero Config - Works out of the box
  • Snapshot Testing - UI component testing
  • Mocking - Functions, modules, and timers
  • Code Coverage - Built-in coverage reports
  • Watch Mode - Interactive test runner
  • Parallel Testing - Fast test execution

Test Structure

  • describe/it - Test organization
  • Matchers - Assertion library
  • Setup/Teardown - beforeEach, afterEach, beforeAll, afterAll
  • Mock Functions - jest.fn(), jest.spyOn()
  • Async Testing - Promises, async/await
  • Test Lifecycle - Hooks and execution order

Advanced Features

  • Custom Matchers - Extend expect
  • Module Mocking - Mock entire modules
  • Timer Mocks - Control time in tests
  • Manual Mocks - mocks directory
  • Configuration - jest.config.js
  • Transformers - Babel, TypeScript support

Best Practices

Test Organization

  • One test file per source file
  • Group related tests with describe
  • Use descriptive test names
  • Follow AAA pattern (Arrange, Act, Assert)
  • Keep tests simple and focused
  • Test behavior, not implementation

Mocking

  • Mock external dependencies
  • Use jest.fn() for function mocks
  • Clear mocks between tests
  • Mock at the right level
  • Avoid over-mocking
  • Document mock behavior

Assertions

  • Use specific matchers
  • One assertion per test when possible
  • Test edge cases
  • Verify error conditions
  • Use snapshots judiciously
  • Provide clear failure messages

Coverage

  • Aim for high coverage (80%+)
  • Don't chase 100% coverage
  • Focus on critical paths
  • Test edge cases and errors
  • Exclude generated code
  • Review coverage reports

Anti-Patterns

Common Mistakes

  • Testing implementation details
  • Too many assertions in one test
  • Sharing state between tests
  • Not cleaning up after tests
  • Ignoring async/await
  • Hard-coding test data

Mocking Issues

  • Over-mocking everything
  • Not resetting mocks
  • Mocking too deep
  • Inconsistent mock data
  • Forgetting to restore mocks
  • Mocking what you don't need

Test Design Problems

  • Tests depending on execution order
  • Flaky tests due to timing
  • No arrange-act-assert structure
  • Testing multiple things at once
  • Duplicate test code
  • Poor test names

Reference Documentation

Detailed material lives alongside this skill and is read on demand:

  • Implementation Examples — Basic Unit Tests, Testing Async Code, Mocking and Spies, Snapshot Testing, Testing React Components with React Testing Library, Timer Mocks, Custom Matchers, Configuration (jest.config.js)

Resources

Official Documentation

Learning Resources

Tools & Extensions

Community Resources

Use it

Copy one of these into your project. Installing also returns the manifest and these snippets.

yaml
targets:
  - https://api.opensmartroute.ai/api/v1/registry/personamanagmentlayer-pcl-jest-expert/manifest   # or paste the manifest below

Manifest

An Open Capability Manifest: the router reads it to know what this does, what it costs and when to pick it.

personamanagmentlayer-pcl-jest-expert.ocm.jsonjson
{
  "ocm": "1",
  "id": "personamanagmentlayer-pcl-jest-expert",
  "kind": "skill",
  "name": "jest-expert",
  "description": "Expert in Jest unit testing framework, mocks, snapshots, coverage reports, watch mode, and custom matchers. Use when the user mentions testing, unit testing, JavaScript, QA, mocking, or snapshots, or when the task involves Jest Framework, Test Structure, Advanced Features, or Basic Unit Tests.",
  "publisher": "personamanagmentlayer",
  "version": "1.0.0",
  "capabilities": {
    "domains": [
      "coding"
    ],
    "tags": [
      "skill-md",
      "testing",
      "unit-testing",
      "jest",
      "javascript",
      "qa",
      "mocking",
      "snapshots",
      "test-coverage",
      "jest-matchers"
    ],
    "languages": [
      "en"
    ]
  },
  "quality_prior": 0.6,
  "examples": [
    "Expert in Jest unit testing framework, mocks, snapshots, coverage reports, watch mode, and custom matchers. Use when the user mentions testing, unit testing, JavaScript, QA, mocking, or snapshots, or when the task involves Jest Framework, Test Structure, Advanced Features, or Basic Unit Tests."
  ],
  "primary": false,
  "metadata": {
    "source": {
      "provider": "skills.sh",
      "repository": "https://github.com/personamanagmentlayer/pcl",
      "path": "stdlib/qa/jest-expert/SKILL.md",
      "ref": "HEAD",
      "url": "https://github.com/personamanagmentlayer/pcl/blob/HEAD/stdlib/qa/jest-expert/SKILL.md",
      "key": "personamanagmentlayer/pcl/stdlib/qa/jest-expert/SKILL.md"
    },
    "allowed_tools": [
      "Read",
      "Write",
      "Edit",
      "Bash",
      "Grep",
      "Glob"
    ]
  },
  "instructions": "# Jest Expert\n\n## Core Concepts\n\n### Jest Framework\n\n- **Zero Config** - Works out of the box\n- **Snapshot Testing** - UI component testing\n- **Mocking** - Functions, modules, and timers\n- **Code Coverage** - Built-in coverage reports\n- **Watch Mode** - Interactive test runner\n- **Parallel Testing** - Fast test execution\n\n### Test Structure\n\n- **describe/it** - Test organization\n- **Matchers** - Assertion library\n- **Setup/Teardown** - beforeEach, afterEach, beforeAll, afterAll\n- **Mock Functions** - jest.fn(), jest.spyOn()\n- **Async Testing** - Promises, async/await\n- **Test Lifecycle** - Hoo",
  "cost": {
    "context_tokens": 1013
  }
}

Fetch it by URL: GET /api/v1/registry/personamanagmentlayer-pcl-jest-expert/manifest?version=1.0.0

Reviews

Star ratings from people who tried it. One review per account; edit yours any time.

No reviews yet. Install it, try it, and be the first to rate it.