# Testing Documentation

**Last Updated**: 2025-01-27  
**Status**: Test Framework Setup

## Test Structure

```
tests/
├── integration/          # Integration tests
│   ├── setup.ts         # Test context setup
│   ├── identity-credential-flow.test.ts
│   └── document-workflow.test.ts
└── e2e/                  # End-to-end tests
    └── user-workflows.test.ts
```

## Running Tests

### All Tests

```bash
pnpm test
```

### Unit Tests Only

```bash
pnpm test -- --run unit
```

### Integration Tests

```bash
pnpm test -- --run integration
```

### E2E Tests

```bash
pnpm test -- --run e2e
```

### With Coverage

```bash
pnpm test -- --coverage
```

## Test Coverage Goals

- **Target**: 80%+ coverage across all services
- **Current**: Expanding coverage
- **Priority**: Critical service paths first

## Test Types

### Unit Tests

- Service-specific tests in `services/*/tests/`
- Test individual functions and modules
- Mock external dependencies

### Integration Tests

- Test service interactions
- Use test database
- Test API endpoints

### E2E Tests

- Test complete user workflows
- Test across multiple services
- Test real-world scenarios

## Test Utilities

### Test Context

- `setupTestContext()` - Initialize all services
- `teardownTestContext()` - Clean up services
- `cleanupDatabase()` - Clean test data

### Fixtures

- Test data factories
- Mock services
- Test helpers

## Best Practices

1. **Isolation**: Each test should be independent
2. **Cleanup**: Always clean up test data
3. **Mocking**: Mock external services
4. **Coverage**: Aim for 80%+ coverage
5. **Speed**: Keep tests fast

---

**Last Updated**: 2025-01-27
