skills/unit-testing-framework/SKILL.md
Write comprehensive unit tests with high coverage using testing frameworks like Jest, pytest, JUnit, or RSpec. Use when writing tests for functions, classes, components, or establishing testing standards.
npx skillsauth add aj-geddes/useful-ai-prompts unit-testing-frameworkInstall 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.
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"; |
development
Implement Zero Trust security model with identity verification, microsegmentation, least privilege access, and continuous monitoring. Use when building secure cloud-native applications.
development
Prevent Cross-Site Scripting (XSS) attacks through input sanitization, output encoding, and Content Security Policy. Use when handling user-generated content in web applications.
tools
Create wireframes and interactive prototypes to visualize user interfaces and gather feedback early. Use tools and techniques to communicate design ideas before development.
development
Implement real-time bidirectional communication with WebSockets including connection management, message routing, and scaling. Use when building real-time features, chat systems, live notifications, or collaborative applications.