testing/SKILL.md
Provides comprehensive testing and TDD guidance. Use for writing tests before implementing new features (TDD, test-driven development, red-green-refactor), creating reproduction tests for bug fixes, running regression tests during refactoring, and checking test coverage during code reviews. Enforces AAA pattern, test-first workflow, and 100% business logic coverage goal. Also covers testing anti-patterns, mock discipline, and testable design.
npx skillsauth add juanjosegongi/skills testingInstall 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.
NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST
Write code before the test? Delete it. Start over. No exceptions.
Implement fresh from tests. Period.
1. RED — Write one failing test for desired behavior
2. Verify — Watch it fail for the RIGHT reason (not typos/errors)
3. GREEN — Write minimal code to pass
4. Verify — All tests pass, output clean
5. REFACTOR — Clean up while staying green
6. Repeat
One behavior. Clear name. Real code (no mocks unless unavoidable).
test('rejects empty email', async () => {
const result = await submitForm({ email: '' });
expect(result.error).toBe('Email required');
});
Run the test. Watch it fail. If it passes, you're testing existing behavior — fix the test. If it errors (not fails), fix the error first.
Write the simplest code to pass. Don't add features, don't over-engineer.
function submitForm(data: FormData) {
if (!data.email?.trim()) {
return { error: 'Email required' };
}
// ...
}
Run the test. Watch it pass. If it fails, fix the code — not the test. If other tests broke, fix them now.
Remove duplication, improve names, extract helpers. Keep all tests green. Don't add behavior.
See TDD.md for detailed examples and workflows.
All tests must follow Arrange-Act-Assert:
it('should create user with valid data', () => {
// Arrange
const userData = { name: 'John', email: '[email protected]' }
// Act
const user = userService.createUser(userData)
// Assert
expect(user.name).toBe('John')
})
/\
/ \ E2E (Few — critical paths only)
/____\ Integration (Medium — API + DB interactions)
/______\ Unit (Many — business logic, fast, isolated)
See TEST-TYPES.md for details.
Business Logic: 100%
Utility Functions: 100%
Service Layer: 90%+
Controllers: 80%+
UI Components: 70%+
See REFERENCE.md for coverage commands and checklists.
new internallySee TESTABLE-DESIGN.md for patterns and anti-patterns.
See TESTING-ANTI-PATTERNS.md for gate functions and examples.
| Excuse | Reality | |--------|---------| | "Too simple to test" | Simple code breaks. Test takes 30 seconds. | | "I'll test after" | Tests passing immediately prove nothing. | | "Already manually tested" | Ad-hoc ≠ systematic. No record, can't re-run. | | "Deleting X hours is wasteful" | Sunk cost fallacy. Keeping unverified code is debt. | | "Need to explore first" | Fine. Throw away exploration, start with TDD. | | "Test hard = skip test" | Hard to test = hard to use. Listen to the test. | | "TDD will slow me down" | TDD is faster than debugging in production. |
All of these mean: delete code, start over with TDD.
Before marking work complete:
| Problem | Solution | |---------|----------| | Don't know how to test | Write the assertion first. Design the wished-for API. | | Test too complicated | Design too complicated. Simplify the interface. | | Must mock everything | Code too coupled. Use dependency injection. | | Test setup huge | Extract helpers. Still complex? Simplify design. | | Bug found | Write failing test reproducing it. Follow TDD cycle. |
development
Guides Dockerfile creation and optimization. Use when Dockerfile or Docker Compose is detected. Supports multi-stage builds, cache optimization, security hardening, and image size minimization.
data-ai
A completely different skill for database operations. Use when working with PostgreSQL queries, schema design, or database migrations.
testing
Another sample skill for testing. Use when the user wants to create widgets with advanced features or mentions beta testing.
testing
A sample skill for testing. Use when the user mentions alpha testing, widget creation, or component design patterns.