Token导航 LogoToken导航

Agent Skill · 开发

jest-generator(笑话生成器)

用于辅助测试设计、自动化测试、用例整理和回归验证。它适合让 Agent 编写单元测试、端到端测试、测试计划或根据失败日志定位问题。使用时需要确认项目测试框架、运行命令和夹具数据,避免为了通过测试而改坏真实逻辑;涉及浏览器或外部服务时,应区分本地模拟、测试环境和生产环境。

jest-generator 是开发类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为需要联网;许可证为 MIT,第三方扫描有未通过项,按安装量在开发类的 21,746 个 Skill 里排第 20,882。

总安装 210周安装 9GitHub Stars 21下载 73核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
MIT

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:jest-generator(笑话生成器)
来源仓库:https://github.com/matteocervelli/llms
仓库路径:skills/jest-generator
安装命令:
npx skills add https://github.com/matteocervelli/llms --skill jest-generator
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/matteocervelli/llms --skill jest-generator

这个 Skill 是做什么的

开发类 Skill 面向写代码、改代码和排查问题,一般会读写仓库文件,部分还会执行构建或测试命令。

jest-generator 用于辅助测试设计、自动化测试、用例整理和回归验证。可帮助 Agent 编写单元测试、端到端测试、测试计划或根据失败日志定位问题。使用时需确认项目测试框架、运行命令和夹具数据;涉及浏览器或外部服务时应区分本地模拟与生产环境。安装前建议确认权限范围、维护状态及是否触发联网、命令执行或文件读写。

适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。

来源仓库内路径:skills/jest-generator

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/matteocervelli/llms --skill jest-generator;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要需要联网,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

jest-generator 怎么安装?

在终端执行 npx skills add https://github.com/matteocervelli/llms --skill jest-generator。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

jest-generator 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

jest-generator 需要什么权限?

权限级别是需要联网。该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

jest-generator 是免费的吗?

来源标注的许可证是 MIT。本站不代收任何费用,也不托管安装包;能否商用、要不要署名,以许可证原文为准。

jest-generator 用的人多吗?

公开数据是累计安装 210 次,近一周安装 9 次,下载 73 次,GitHub 21 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

jest-generator 安全吗?

第三方扫描有未通过项,风险较高。除非你确认过源码,否则不建议直接安装到常用环境。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 3 个目录同时收录,说明这个 Skill 流传比较广。
  • 许可证明确为 MIT,商用和分发边界好判断。

先想清楚的地方

  • 第三方扫描存在提醒项或未通过项,需要人工逐条确认。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理开发类任务、又不想每次都手写提示词的人。

不太适合

  • 需要厂商级技术支持和 SLA 的生产系统。

开发类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
skill-vetter

技能审查员 · OpenClaw

8,779,018986操作浏览器MIT-0通过
ontology

本体论 · OpenClaw

6,636,960576只读MIT-0通过
entra-app-registration

内部应用程序注册 · Codex、Claude

6,631,872764接触敏感数据未明确通过
entra-app-registration

内部应用程序注册 · Codex、Claude

3,757,680201接触敏感数据未明确通过
nano-banana-pro

纳米香蕉专业版 · OpenClaw

3,526,898364接触敏感数据MIT-0有提醒
jest-generator

笑话生成器 · 本页

21021需要联网MIT未通过

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

Jest Generator Skill

Purpose

This skill generates Jest-based unit tests for JavaScript and TypeScript code, following Jest conventions, best practices, and project standards. It creates comprehensive test suites with proper mocking, describe blocks, and code organization.

When to Use

  • Generate Jest tests for JavaScript/TypeScript modules
  • Create test files for React components
  • Add missing test coverage to existing JS/TS code
  • Need Jest-specific patterns (mocks, spies, snapshots)

Test File Naming Convention

Source to Test Mapping:

  • Source: src/components/Feature.tsx
  • Test: src/components/Feature.test.tsx
  • Pattern: <source_filename>.test.ts or <source_filename>.test.js

Examples:

  • src/utils/validator.ts → src/utils/validator.test.ts
  • src/models/User.ts → src/models/User.test.ts
  • src/services/api.js → src/services/api.test.js
  • src/components/Button.tsx → src/components/Button.test.tsx

Jest Test Generation Workflow

1. Analyze JavaScript/TypeScript Source Code

Read the source file:

# Read the source to understand structure
cat src/components/Feature.tsx

Identify test targets:

  • Exported functions to test
  • Classes and methods
  • React components (if applicable)
  • Error conditions
  • Edge cases
  • Dependencies and imports

Output: List of functions/classes/components requiring tests


2. Generate Test File Structure

Create test file with proper naming:

/**
 * Unit tests for [module name]
 *
 * Tests cover:
 * - [Functionality 1]
 * - [Functionality 2]
 * - Error handling and edge cases
 */

import { functionToTest, ClassToTest, ComponentToTest } from './Feature';
import { mockDependency } from './__mocks__/dependency';

// Mock external dependencies
jest.mock('./dependency');
jest.mock('external-library');

// ============================================================================
// Test Setup
// ============================================================================

describe('ModuleName', () => {
  // Setup before each test
  beforeEach(() => {
    jest.clearAllMocks();
  });

  // Cleanup after each test
  afterEach(() => {
    jest.restoreAllMocks();
  });

  // ========================================================================
  // Class Tests
  // ========================================================================

  describe('ClassName', () => {
    let instance: ClassToTest;

    beforeEach(() => {
      instance = new ClassToTest();
    });

    describe('constructor', () => {
      it('should initialize with valid parameters', () => {
        // Arrange & Act
        const instance = new ClassToTest({ param: 'value' });

        // Assert
        expect(instance.param).toBe('value');
        expect(instance.initialized).toBe(true);
      });

      it('should throw error with invalid parameters', () => {
        // Arrange
        const invalidParams = null;

        // Act & Assert
        expect(() => new ClassToTest(invalidParams)).toThrow('Invalid parameters');
      });
    });

    describe('method', () => {
      it('should return expected result with valid input', () => {
        // Arrange
        const input = { name: 'test', value: 123 };

        // Act
        const result = instance.method(input);

        // Assert
        expect(result.processed).toBe(true);
        expect(result.name).toBe('test');
        expect(result.value).toBe(123);
      });

      it('should throw error with invalid input', () => {
        // Arrange
        const invalidInput = null;

        // Act & Assert
        expect(() => instance.method(invalidInput)).toThrow('Invalid input');
      });

      it('should handle edge case with empty input', () => {
        // Arrange
        const emptyInput = {};

        // Act
        const result = instance.method(emptyInput);

        // Assert
        expect(result).toEqual({});
      });
    });
  });

  // ========================================================================
  // Function Tests
  // ========================================================================

  describe('functionToTest', () => {
    it('should return expected result with valid input', () => {
      // Arrange
      const input = { key: 'value' };
      const expected = { processed: true, key: 'value' };

      // Act
      const result = functionToTest(input);

      // Assert
      expect(result).toEqual(expected);
    });

    it('should handle null input', () => {
      // Arrange
      const input = null;

      // Act & Assert
      expect(() => functionToTest(input)).toThrow('Input cannot be null');
    });

    it('should handle undefined input', () => {
      // Arrange
      const input = undefined;

      // Act
      const result = functionToTest(input);

      // Assert
      expect(result).toBeUndefined();
    });
  });

  // ========================================================================
  // Tests with Mocks
  // ========================================================================

  describe('functionWithDependency', () => {
    it('should call dependency with correct parameters', () => {
      // Arrange
      const input = { key: 'value' };
      const mockDep = jest.fn().mockReturnValue({ status: 'success' });

      // Act
      const result = functionWithDependency(input, mockDep);

      // Assert
      expect(mockDep).toHaveBeenCalledWith(input);
      expect(mockDep).toHaveBeenCalledTimes(1);
      expect(result.status).toBe('success');
    });

    it('should handle dependency error', () => {
      // Arrange
      const input = { key: 'value' };
      const mockDep = jest.fn().mockRejectedValue(new Error('API error'));

      // Act & Assert
      await expect(functionWithDependency(input, mockDep))
        .rejects.toThrow('API error');
    });
  });

  // ========================================================================
  // Async Tests
  // ========================================================================

  describe('asyncFunction', () => {
    it('should resolve with expected result', async () => {
      // Arrange
      const input = { key: 'value' };

      // Act
      const result = await asyncFunction(input);

      // Assert
      expect(result.success).toBe(true);
      expect(result.data).toEqual(input);
    });

    it('should reject with error on failure', async () => {
      // Arrange
      const invalidInput = null;

      // Act & Assert
      await expect(asyncFunction(invalidInput))
        .rejects.toThrow('Invalid input');
    });

    it('should handle timeout', async () => {
      // Arrange
      jest.useFakeTimers();
      const promise = asyncFunctionWithTimeout();

      // Act
      jest.advanceTimersByTime(5000);

      // Assert
      await expect(promise).rejects.toThrow('Timeout');
      jest.useRealTimers();
    });
  });

  // ========================================================================
  // Parametrized Tests (using test.each)
  // ========================================================================

  describe('validation', () => {
    it.each([
      ['valid@email.com', true],
      ['invalid.email', false],
      ['', false],
      [null, false],
      ['@no-user.com', false],
    ])('should validate email "%s" as %s', (email, expected) => {
      // Act
      const result = validateEmail(email);

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

  describe('permissions', () => {
    it.each([
      ['admin', 'all'],
      ['moderator', 'edit'],
      ['user', 'read'],
      ['guest', 'none'],
    ])('should return "%s" permission for %s user', (userType, expected) => {
      // Arrange
      const user = { type: userType };

      // Act
      const result = getPermissions(user);

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

Deliverable: Complete Jest test file


Jest-Specific Patterns

1. Mocking

Mock entire module:

jest.mock('./api', () => ({
  fetchData: jest.fn(),
  postData: jest.fn(),
}));

Mock specific function:

import { fetchData } from './api';

jest.mock('./api');

describe('Component', () => {
  it('should fetch data', async () => {
    // Arrange
    (fetchData as jest.Mock).mockResolvedValue({ data: 'test' });

    // Act
    const result = await getData();

    // Assert
    expect(result.data).toBe('test');
  });
});

Mock with implementation:

const mockFn = jest.fn((x: number) => x * 2);

// Use the mock
expect(mockFn(2)).toBe(4);
expect(mockFn).toHaveBeenCalledWith(2);

Spy on method:

const obj = {
  method: () => 'original',
};

const spy = jest.spyOn(obj, 'method').mockReturnValue('mocked');

expect(obj.method()).toBe('mocked');
expect(spy).toHaveBeenCalled();

spy.mockRestore(); // Restore original implementation

2. Async Testing

Testing promises:

it('should resolve with data', async () => {
  // Using async/await
  const result = await asyncFunction();
  expect(result).toBeDefined();
});

it('should reject with error', async () => {
  // Using async/await with expect
  await expect(asyncFunction()).rejects.toThrow('Error');
});

it('should handle promise chain', () => {
  // Using .then()
  return asyncFunction().then(result => {
    expect(result).toBeDefined();
  });
});

Testing async with done callback:

it('should complete async operation', (done) => {
  asyncOperation((result) => {
    expect(result).toBe('complete');
    done();
  });
});

3. Timers

Mock timers:

describe('with fake timers', () => {
  beforeEach(() => {
    jest.useFakeTimers();
  });

  afterEach(() => {
    jest.useRealTimers();
  });

  it('should execute after timeout', () => {
    const callback = jest.fn();

    setTimeout(callback, 1000);

    // Fast-forward time
    jest.advanceTimersByTime(1000);

    expect(callback).toHaveBeenCalled();
  });

  it('should run all timers', () => {
    const callback = jest.fn();

    setTimeout(callback, 1000);
    setTimeout(callback, 2000);

    jest.runAllTimers();

    expect(callback).toHaveBeenCalledTimes(2);
  });
});

4. Snapshots

Snapshot testing:

it('should match snapshot', () => {
  const data = {
    name: 'test',
    value: 123,
    nested: {
      field: 'value',
    },
  };

  expect(data).toMatchSnapshot();
});

it('should match inline snapshot', () => {
  const result = formatData({ name: 'test' });

  expect(result).toMatchInlineSnapshot(`
    {
      "formatted": true,
      "name": "test",
    }
  `);
});

5. Setup and Teardown

Test lifecycle hooks:

describe('TestSuite', () => {
  beforeAll(() => {
    // Runs once before all tests in this describe block
  });

  afterAll(() => {
    // Runs once after all tests in this describe block
  });

  beforeEach(() => {
    // Runs before each test in this describe block
  });

  afterEach(() => {
    // Runs after each test in this describe block
  });

  it('test 1', () => {});
  it('test 2', () => {});
});

6. Matchers

Common Jest matchers:

// Equality
expect(value).toBe(expected);          // Strict equality (===)
expect(value).toEqual(expected);        // Deep equality
expect(value).toStrictEqual(expected);  // Strict deep equality

// Truthiness
expect(value).toBeTruthy();
expect(value).toBeFalsy();
expect(value).toBeNull();
expect(value).toBeUndefined();
expect(value).toBeDefined();

// Numbers
expect(value).toBeGreaterThan(3);
expect(value).toBeGreaterThanOrEqual(3);
expect(value).toBeLessThan(5);
expect(value).toBeLessThanOrEqual(5);
expect(value).toBeCloseTo(0.3, 5); // For floating point

// Strings
expect(string).toMatch(/pattern/);
expect(string).toContain('substring');

// Arrays and iterables
expect(array).toContain(item);
expect(array).toHaveLength(3);
expect(array).toContainEqual(item);

// Objects
expect(obj).toHaveProperty('key');
expect(obj).toHaveProperty('key', value);
expect(obj).toMatchObject({ key: value });

// Functions
expect(fn).toThrow();
expect(fn).toThrow('error message');
expect(fn).toThrow(ErrorClass);

// Promises
await expect(promise).resolves.toBe(value);
await expect(promise).rejects.toThrow();

// Mock functions
expect(mockFn).toHaveBeenCalled();
expect(mockFn).toHaveBeenCalledTimes(2);
expect(mockFn).toHaveBeenCalledWith(arg1, arg2);
expect(mockFn).toHaveBeenLastCalledWith(arg);

React Component Testing

Basic Component Test

import React from 'react';
import { render, screen, fireEvent } from '@testing-library/react';
import '@testing-library/jest-dom';
import { Button } from './Button';

describe('Button', () => {
  it('should render with text', () => {
    // Arrange & Act
    render(<Button>Click me</Button>);

    // Assert
    expect(screen.getByText('Click me')).toBeInTheDocument();
  });

  it('should call onClick when clicked', () => {
    // Arrange
    const handleClick = jest.fn();
    render(<Button onClick={handleClick}>Click me</Button>);

    // Act
    fireEvent.click(screen.getByText('Click me'));

    // Assert
    expect(handleClick).toHaveBeenCalledTimes(1);
  });

  it('should be disabled when disabled prop is true', () => {
    // Arrange & Act
    render(<Button disabled>Click me</Button>);

    // Assert
    expect(screen.getByText('Click me')).toBeDisabled();
  });
});

Component with Hooks

import { renderHook, act } from '@testing-library/react';
import { useCounter } from './useCounter';

describe('useCounter', () => {
  it('should initialize with default value', () => {
    // Arrange & Act
    const { result } = renderHook(() => useCounter());

    // Assert
    expect(result.current.count).toBe(0);
  });

  it('should increment count', () => {
    // Arrange
    const { result } = renderHook(() => useCounter());

    // Act
    act(() => {
      result.current.increment();
    });

    // Assert
    expect(result.current.count).toBe(1);
  });
});

Running Jest

Basic commands:

# Run all tests
npm test
# or
jest

# Run specific file
jest src/components/Feature.test.ts

# Run tests matching pattern
jest Feature

# Run with coverage
jest --coverage

# Run in watch mode
jest --watch

# Run with verbose output
jest --verbose

# Update snapshots
jest --updateSnapshot
# or
jest -u

Coverage commands:

# Generate coverage report
jest --coverage

# View HTML report
open coverage/lcov-report/index.html

# Coverage with threshold
jest --coverage --coverageThreshold='{"global":{"branches":80,"functions":80,"lines":80,"statements":80}}'

Best Practices

  1. Use descriptive test names: should <expected> when <condition>
  2. Organize with describe blocks: Group related tests
  3. Use beforeEach/afterEach: Clean setup and teardown
  4. Mock external dependencies: Isolate unit under test
  5. Test user behavior: For components, test what users see/do
  6. Use test.each for similar tests: Reduce duplication
  7. Keep tests independent: No test depends on another
  8. Test edge cases: Null, undefined, empty values
  9. Test error conditions: Exceptions and rejections
  10. Use appropriate matchers: Choose the most specific matcher

TypeScript-Specific Considerations

Type-safe mocks:

import { MockedFunction } from 'jest-mock';

const mockFn: MockedFunction<typeof realFunction> = jest.fn();

Type assertions:

const mock = jest.fn() as jest.MockedFunction<typeof original>;

Generic mocks:

interface ApiResponse<T> {
  data: T;
  status: number;
}

const mockApi = jest.fn<Promise<ApiResponse<User>>, [string]>();

Quality Checklist

Before marking tests complete:

  • Test file properly named (<module>.test.ts)
  • All exported functions/classes/components tested
  • Happy path tests included
  • Edge case tests included (null, undefined, empty)
  • Error condition tests included
  • External dependencies mocked
  • Tests organized with describe blocks
  • beforeEach/afterEach used for setup/cleanup
  • Test names are descriptive
  • All tests pass
  • Coverage ≥ 80%
  • No snapshot tests without purpose
  • Tests run quickly

Integration with Testing Workflow

Input: JavaScript/TypeScript source file to test Process: Analyze → Generate structure → Write tests → Run & verify Output: Jest test file with ≥ 80% coverage Next Step: Integration testing or code review


Remember

  • Follow naming convention: <source_file>.test.ts
  • Use describe blocks for organization
  • Mock external dependencies to isolate tests
  • Test behavior, not implementation
  • Use appropriate matchers for clarity
  • Aim for 80%+ coverage
  • Keep tests fast and independent
  • For React: test what users see and do

平台分布

OpenCode

27.73%
按下载量换算20

Antigravity

23.58%
按下载量换算17

Claude Code

18.08%
按下载量换算13

Codex

12.78%
按下载量换算9

Gemini CLI

7.72%
按下载量换算6

windsurf

3.97%
按下载量换算3

安全审计

Gen Agent Trust Hub

未通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在提醒或未通过项,安装前请自行复核。

继续浏览同类 Skills