``` ╱╲ ╱ ╲ E2E (few) ╱────╲ ╱ ╲ Integration (some) ╱────────╲ ╱ ╲ Unit (many) ╱────────────╲ ``` ```typescript // user.service.test.ts import { describe, it, expect, vi } from 'vitest' import { UserService } from './user.service' describe('UserService', () => { it('should create user', async () => { const mockRepo = { create: vi.fn().mockResolvedValue({ id: '1', email: 'test@test.com' }) } co
Scanned 9/7/2026
Install to Claude Code
npx -y skills add modbender/skill-library-mcp --skill testing-fundamentals --agent claude-codeInstalls into .claude/skills of the current project.
Are you the author of Testing Fundamentals?
Add the live security badge to your README — it updates automatically with every re-scan.
[](https://www.skillsdirectory.com/skills/modbender-testing-fundamentals)More formats (shields.io, HTML) on the badges page.
# Testing Fundamentals
## Test Pyramid
```
╱╲
╱ ╲ E2E (few)
╱────╲
╱ ╲ Integration (some)
╱────────╲
╱ ╲ Unit (many)
╱────────────╲
```
## Unit Testing
```typescript
// user.service.test.ts
import { describe, it, expect, vi } from 'vitest'
import { UserService } from './user.service'
describe('UserService', () => {
it('should create user', async () => {
const mockRepo = {
create: vi.fn().mockResolvedValue({ id: '1', email: 'test@test.com' })
}
const service = new UserService(mockRepo)
const user = await service.create({ email: 'test@test.com', name: 'Test' })
expect(user.email).toBe('test@test.com')
expect(mockRepo.create).toHaveBeenCalled()
})
})
```
## Integration Testing
```typescript
// api/users.test.ts
import { describe, it, expect, beforeAll } from 'vitest'
import request from 'supertest'
import { app } from '../src/index'
describe('POST /users', () => {
it('should create user', async () => {
const res = await request(app)
.post('/api/users')
.send({ email: 'test@test.com', name: 'Test' })
expect(res.status).toBe(201)
expect(res.body.email).toBe('test@test.com')
})
})
```
## Checklist
- [ ] Set up test framework (Vitest/Jest)
- [ ] Write unit tests for services
- [ ] Add integration tests for API
- [ ] Use test fixtures
- [ ] Mock external services
- [ ] Aim for 80% coverage on core logic
Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.
No comments yet. Be the first to comment!