test-driven-development

Solid

TDD red-green-refactor cycle, test structure, mocking patterns for Vitest/Jest. Use when starting a new feature, fixing a bug, or refactoring — write the test first, then the implementation.

Testing & QA 30 stars 9 forks Updated 5 days ago MIT

Install

View on GitHub

Quality Score: 82/100

Stars 20%
50
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
80
License 10%
100
Description 5%
100

Skill Content

# Test-Driven Development ## The Red-Green-Refactor Cycle ``` RED → Write a failing test that describes the desired behavior GREEN → Write the minimum code to make it pass (no more, no less) REFACTOR → Improve the code without changing behavior; tests stay green ``` Never skip the RED step. If you write code before the test, you lose confidence that your test actually tests anything. ## Test Structure: AAA Pattern ```typescript // Arrange → Act → Assert — every test follows this shape describe('UserService', () => { describe('create', () => { it('should hash the password before saving', async () => { // ARRANGE — set up everything the test needs const dto: CreateUserDto = { email: 'jane@example.com', password: 'S3cureP@ss!', name: 'Jane Doe', } const mockRepo = createMockUserRepo() const mockHasher = createMockHasher({ result: 'hashed_password' }) const sut = new UserService(mockRepo, mockHasher) // ACT — call the thing under test await sut.create(dto) // ASSERT — verify outcomes expect(mockHasher.hash).toHaveBeenCalledWith('S3cureP@ss!') expect(mockRepo.save).toHaveBeenCalledWith( expect.objectContaining({ passwordHash: 'hashed_password' }) ) }) }) }) ``` ## Vitest Setup ```typescript // vitest.config.ts import { defineConfig } from 'vitest/config' import tsconfigPaths from 'vite-tsconfig-paths' export default defineConfig({ plugins...

Details

Author
sabahattink
Repository
sabahattink/antigravity-fullstack-hq
Created
8 months ago
Last Updated
5 days ago
Language
PowerShell
License
MIT

Integrates with

Similar Skills

Semantically similar based on skill content — not just same category