The Agent Skills Directory
npx skills add https://smithery.ai/skills/FortiumPartners/jest-test-framework为 JavaScript 和 TypeScript 项目提供全面的 Jest 测试执行和生成能力,支持:
根据错误报告或功能描述创建测试文件:
node generate-test.js \
--source src/components/Button.js \
--output tests/components/Button.test.js \
--type unit \
--description "Button component fails to handle click events"
运行 Jest 测试并返回结构化结果:
node run-test.js \
--file tests/components/Button.test.js \
--config jest.config.js
--source <path> - 待测试的源文件(必需)--output <path> - 输出测试文件路径(必需)--type <unit|integration|e2e> - 测试类型(默认:unit)--description <text> - 错误描述或测试目的--framework <react|node|express> - 特定框架的模式--file <path> - 要执行的测试文件(必需)--config <path> - Jest 配置文件(可选)--coverage - 运行并生成覆盖率报告--watch - 以监视模式运行(不推荐在 CI 中使用)返回包含生成的测试文件信息的 JSON:
{
"success": true,
"testFile": "tests/components/Button.test.js",
"testCount": 3,
"template": "unit-test",
"framework": "react"
}
返回包含测试结果的 JSON:
{
"success": false,
"passed": 2,
"failed": 1,
"total": 3,
"duration": 1.234,
"failures": [
{
"test": "Button handles click events",
"error": "Expected onClick to be called",
"file": "tests/components/Button.test.js",
"line": 15
}
]
}
用于隔离测试单个函数或组件:
用于测试多个组件协同工作:
用于测试完整的用户流程:
import { render, fireEvent, screen } from '@testing-library/react';
import { Button } from '../components/Button';
describe('Button', () => {
it('handles click events', () => {
const onClick = jest.fn();
render(<Button onClick={onClick}>Click me</Button>);
fireEvent.click(screen.getByText('Click me'));
expect(onClick).toHaveBeenCalled();
});
});
const request = require('supertest');
const app = require('../app');
describe('GET /api/users', () => {
it('returns list of users', async () => {
const res = await request(app).get('/api/users');
expect(res.status).toBe(200);
expect(res.body).toBeInstanceOf(Array);
});
});
deep-debugger 代理使用此技能进行:
示例工作流:
1. deep-debugger 接收错误报告
2. 调用 test-detector 识别 Jest
3. 调用 jest-test/generate-test.js 创建失败的测试
4. 调用 jest-test/run-test.js 验证测试失败
5. 将修复委托给相应的专家代理
6. 调用 jest-test/run-test.js 验证修复
需要在项目中安装 Jest:
npm install --save-dev jest @types/jest
对于 React 测试:
npm install --save-dev @testing-library/react @testing-library/jest-dom
{
"success": false,
"error": "Source file not found",
"file": "src/components/Missing.js"
}
{
"success": false,
"error": "Jest configuration not found",
"config": "jest.config.js"
}
每周安装次数
–
来源
首次出现
–
Provide comprehensive Jest test execution and generation capabilities for JavaScript and TypeScript projects, supporting:
Create a test file from a bug report or feature description:
node generate-test.js \
--source src/components/Button.js \
--output tests/components/Button.test.js \
--type unit \
--description "Button component fails to handle click events"
Run Jest tests and return structured results:
node run-test.js \
--file tests/components/Button.test.js \
--config jest.config.js
--source <path> - Source file to test (required)--output <path> - Output test file path (required)广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
--type <unit|integration|e2e> - Test type (default: unit)--description <text> - Bug description or test purpose--framework <react|node|express> - Framework-specific patterns--file <path> - Test file to execute (required)--config <path> - Jest config file (optional)--coverage - Run with coverage report--watch - Run in watch mode (not recommended for CI)Returns JSON with generated test file information:
{
"success": true,
"testFile": "tests/components/Button.test.js",
"testCount": 3,
"template": "unit-test",
"framework": "react"
}
Returns JSON with test results:
{
"success": false,
"passed": 2,
"failed": 1,
"total": 3,
"duration": 1.234,
"failures": [
{
"test": "Button handles click events",
"error": "Expected onClick to be called",
"file": "tests/components/Button.test.js",
"line": 15
}
]
}
For testing individual functions or components in isolation:
For testing multiple components working together:
For testing complete user journeys:
import { render, fireEvent, screen } from '@testing-library/react';
import { Button } from '../components/Button';
describe('Button', () => {
it('handles click events', () => {
const onClick = jest.fn();
render(<Button onClick={onClick}>Click me</Button>);
fireEvent.click(screen.getByText('Click me'));
expect(onClick).toHaveBeenCalled();
});
});
const request = require('supertest');
const app = require('../app');
describe('GET /api/users', () => {
it('returns list of users', async () => {
const res = await request(app).get('/api/users');
expect(res.status).toBe(200);
expect(res.body).toBeInstanceOf(Array);
});
});
The deep-debugger agent uses this skill for:
Example workflow:
1. deep-debugger receives bug report
2. Invokes test-detector to identify Jest
3. Invokes jest-test/generate-test.js to create failing test
4. Invokes jest-test/run-test.js to validate test fails
5. Delegates fix to appropriate specialist agent
6. Invokes jest-test/run-test.js to verify fix
Requires Jest to be installed in the project:
npm install --save-dev jest @types/jest
For React testing:
npm install --save-dev @testing-library/react @testing-library/jest-dom
{
"success": false,
"error": "Source file not found",
"file": "src/components/Missing.js"
}
{
"success": false,
"error": "Jest configuration not found",
"config": "jest.config.js"
}
Weekly Installs
–
Source
First Seen
–
Vue 3 调试指南:解决响应式、计算属性与监听器常见错误
10,500 周安装