From aj-geddes-useful-ai-prompts-4
Write unit tests with high coverage using Jest, pytest, JUnit, or RSpec. Covers AAA pattern, mocking, async code, and edge cases. Use when establishing testing standards.
How this skill is triggered — by the user, by Claude, or both
Slash command
/aj-geddes-useful-ai-prompts-4:unit-testing-frameworkThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
- [Overview](#overview)
Write effective unit tests that are fast, isolated, readable, and maintainable following industry best practices and AAA (Arrange-Act-Assert) pattern.
Minimal working example:
// Jest/JavaScript example
describe("UserService", () => {
describe("createUser", () => {
it("should create user with valid data", async () => {
// Arrange - Set up test data and dependencies
const userData = {
email: "[email protected]",
firstName: "John",
lastName: "Doe",
};
const mockDatabase = createMockDatabase();
const service = new UserService(mockDatabase);
// Act - Execute the function being tested
const result = await service.createUser(userData);
// Assert - Verify the outcome
expect(result.id).toBeDefined();
expect(result.email).toBe("[email protected]");
expect(mockDatabase.save).toHaveBeenCalledWith(
expect.objectContaining(userData),
);
});
});
});
Detailed implementations in the references/ directory:
| Guide | Contents |
|---|---|
| Test Structure (AAA Pattern) | Test Structure (AAA Pattern) |
| Test Cases by Language | Test Cases by Language |
| Mocking & Test Doubles | Mocking & Test Doubles |
| Testing Async Code | Testing Async Code, Test Coverage |
| Testing Edge Cases | Testing Edge Cases |
| Example: Complete Test Suite | import { UserService } from "./user-service"; |
npx claudepluginhub joshuarweaver/cascade-code-languages-misc-1 --plugin aj-geddes-useful-ai-prompts-4Provides strategies for writing maintainable unit, integration, and E2E tests using AAA pattern, mocking, test naming, and organization. Useful for TDD and test infrastructure.
Generates comprehensive unit tests from source code covering happy paths, edge cases, and error conditions. Supports Jest, Vitest, Mocha, pytest, JUnit 5, and Go testing.
Generates unit, integration, and E2E test suites with AAA pattern for Jest (JS/TS), Pytest (Python), and Go. Useful for writing tests, improving coverage, or setting up frameworks.