skills/dev-utils-skills/test-writer/SKILL.md
Generates unit, integration, and end-to-end tests using frameworks like pytest, Jest, JUnit, and Playwright. Use when the user needs to write tests for existing code, create test suites for a module, add edge-case coverage, or set up a testing framework from scratch.
npx skillsauth add teachingai/agent-skills test-writerInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Use this skill whenever the user wants to:
import pytest
from decimal import Decimal
from orders import calculate_order_total, OrderItem
class TestCalculateOrderTotal:
def test_single_item_no_discount(self):
items = [OrderItem(price=Decimal("10.00"), quantity=2)]
result = calculate_order_total(items, discount_pct=0.0, tax_rate=0.08)
assert result == Decimal("21.60")
def test_applies_discount_before_tax(self):
items = [OrderItem(price=Decimal("100.00"), quantity=1)]
result = calculate_order_total(items, discount_pct=0.1, tax_rate=0.10)
assert result == Decimal("99.00")
def test_empty_items_returns_zero(self):
result = calculate_order_total([], discount_pct=0.0, tax_rate=0.08)
assert result == Decimal("0.00")
def test_invalid_discount_raises_error(self):
items = [OrderItem(price=Decimal("10.00"), quantity=1)]
with pytest.raises(ValueError, match="discount_pct must be 0-1"):
calculate_order_total(items, discount_pct=1.5)
import request from 'supertest';
import { app } from '../src/app';
import { db } from '../src/database';
describe('POST /api/users', () => {
afterEach(async () => { await db.query('DELETE FROM users WHERE email LIKE $1', ['%@test.com']); });
it('creates a user and returns 201', async () => {
const res = await request(app)
.post('/api/users')
.send({ name: 'Alice', email: '[email protected]' })
.expect(201);
expect(res.body).toMatchObject({ name: 'Alice', email: '[email protected]' });
});
it('returns 400 for missing email', async () => {
await request(app).post('/api/users').send({ name: 'Bob' }).expect(400);
});
});
test_<behavior>_when_<condition> or it('should <outcome> when <input>')测试编写, test writing, unit test, integration test, e2e test, pytest, Jest, JUnit, Vitest, Playwright, mock, fixture, 单元测试, 集成测试, 端到端测试, test coverage
development
Guidance for Next.js using the official docs at nextjs.org/docs. Use when the user needs Next.js concepts, configuration, routing, data fetching, or API reference details.
tools
Provides comprehensive guidance for Flask framework including routing, templates, forms, database integration, extensions, and deployment. Use when the user asks about Flask, needs to create web applications, implement routes, or build Python web services.
development
Provides comprehensive guidance for FastAPI framework including routing, request validation, dependency injection, async operations, OpenAPI documentation, and database integration. Use when the user asks about FastAPI, needs to create REST APIs, or build high-performance Python web services.
development
Provides comprehensive guidance for Django framework including models, views, templates, forms, admin, REST framework, and deployment. Use when the user asks about Django, needs to create web applications, implement models and views, or build Django REST APIs.