test-automator by charon-fan/agent-playbook
npx skills add https://github.com/charon-fan/agent-playbook --skill test-automator精通为各种框架和语言创建和维护自动化测试。
当您:
/\
/E2E\ - 数量少、成本高、速度慢
/------\
/ 集成测试 \ - 数量适中
/--------------\
/ 单元测试 \ - 数量多、成本低、速度快
/------------------\
describe('UserService', () => {
describe('createUser', () => {
it('should create a user with valid data', async () => {
// 安排
const userData = {
name: 'John Doe',
email: 'john@example.com'
};
// 执行
const user = await userService.create(userData);
// 断言
expect(user.id).toBeDefined();
expect(user.email).toBe(userData.email);
});
it('should throw error for invalid email', async () => {
// 安排
const userData = { email: 'invalid' };
// 执行 & 断言
await expect(userService.create(userData))
.rejects.toThrow('Invalid email');
});
});
});
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
describe('POST /api/users', () => {
it('should create a user', async () => {
const response = await request(app)
.post('/api/users')
.send({
name: 'John Doe',
email: 'john@example.com'
})
.expect(201)
.expect((res) => {
expect(res.body.id).toBeDefined();
expect(res.body.email).toBe('john@example.com');
});
});
});
test('user can login', async ({ page }) => {
await page.goto('/login');
await page.fill('[name="email"]', 'user@example.com');
await page.fill('[name="password"]', 'password123');
await page.click('button[type="submit"]');
await expect(page).toHaveURL('/dashboard');
await expect(page.locator('h1')).toContainText('Welcome');
});
| 类型 | 目标 |
|---|---|
| 代码行 | > 80% |
| 分支 | > 75% |
| 函数 | > 80% |
| 语句 | > 80% |
# Jest
npm test -- --coverage
# Python (pytest-cov)
pytest --cov=src --cov-report=html
# Go
go test -coverprofile=coverage.out
go tool cover -html=coverage.out
// 好:描述正在测试的内容
it('should reject invalid email addresses')
// 好:描述场景和结果
it('returns 401 when user provides invalid credentials')
// 差:模糊不清
it('works correctly')
| 语言 | 框架 | 命令 |
|---|---|---|
| TypeScript/JS | Jest, Vitest | npm test |
| Python | pytest | pytest |
| Go | testing | go test |
| Java | JUnit | mvn test |
| Rust | built-in | cargo test |
生成测试样板代码:
python scripts/generate_test.py <filename>
检查测试覆盖率:
python scripts/coverage_report.py
references/best-practices.md - 测试最佳实践references/examples/ - 特定框架示例references/mocking.md - 模拟指南每周安装次数
57
代码仓库
GitHub 星标数
11
首次出现时间
2026年1月22日
安全审计
安装于
opencode49
codex48
gemini-cli48
cursor47
github-copilot43
amp43
Expert in creating and maintaining automated tests for various frameworks and languages.
Activates when you:
/\
/E2E\ - Few, expensive, slow
/------\
/ Integration \ - Moderate number
/--------------\
/ Unit Tests \ - Many, cheap, fast
/------------------\
describe('UserService', () => {
describe('createUser', () => {
it('should create a user with valid data', async () => {
// Arrange
const userData = {
name: 'John Doe',
email: 'john@example.com'
};
// Act
const user = await userService.create(userData);
// Assert
expect(user.id).toBeDefined();
expect(user.email).toBe(userData.email);
});
it('should throw error for invalid email', async () => {
// Arrange
const userData = { email: 'invalid' };
// Act & Assert
await expect(userService.create(userData))
.rejects.toThrow('Invalid email');
});
});
});
describe('POST /api/users', () => {
it('should create a user', async () => {
const response = await request(app)
.post('/api/users')
.send({
name: 'John Doe',
email: 'john@example.com'
})
.expect(201)
.expect((res) => {
expect(res.body.id).toBeDefined();
expect(res.body.email).toBe('john@example.com');
});
});
});
test('user can login', async ({ page }) => {
await page.goto('/login');
await page.fill('[name="email"]', 'user@example.com');
await page.fill('[name="password"]', 'password123');
await page.click('button[type="submit"]');
await expect(page).toHaveURL('/dashboard');
await expect(page.locator('h1')).toContainText('Welcome');
});
| Type | Target |
|---|---|
| Lines | > 80% |
| Branches | > 75% |
| Functions | > 80% |
| Statements | > 80% |
# Jest
npm test -- --coverage
# Python (pytest-cov)
pytest --cov=src --cov-report=html
# Go
go test -coverprofile=coverage.out
go tool cover -html=coverage.out
// Good: Describes what is being tested
it('should reject invalid email addresses')
// Good: Describes the scenario and outcome
it('returns 401 when user provides invalid credentials')
// Bad: Vague
it('works correctly')
| Language | Framework | Command |
|---|---|---|
| TypeScript/JS | Jest, Vitest | npm test |
| Python | pytest | pytest |
| Go | testing | go test |
| Java | JUnit | mvn test |
| Rust | built-in | cargo test |
Generate test boilerplate:
python scripts/generate_test.py <filename>
Check test coverage:
python scripts/coverage_report.py
references/best-practices.md - Testing best practicesreferences/examples/ - Framework-specific examplesreferences/mocking.md - Mocking guidelinesWeekly Installs
57
Repository
GitHub Stars
11
First Seen
Jan 22, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
opencode49
codex48
gemini-cli48
cursor47
github-copilot43
amp43
agent-browser 浏览器自动化工具 - Vercel Labs 命令行网页操作与测试
152,900 周安装
Next.js 16 + shadcn/ui 最佳实践:构建独特生产级界面,避免千篇一律AI风格
160 周安装
Mermaid.js v11 图表生成教程 - 流程图、时序图、类图等24+图表类型
160 周安装
summarize:命令行AI摘要工具,支持URL、PDF、YouTube视频内容快速总结
160 周安装
SvelteKit 2 + Svelte 5 + Tailwind v4 集成指南 - 现代Web应用开发技能
160 周安装
日志记录最佳实践指南:结构化日志、安全合规与性能优化
161 周安装
Microsoft 365 租户管理器:自动化脚本工具,助力全局管理员高效管理用户与安全策略
161 周安装