Backup: 2025-06-07 19:48 - Script test
[Restore from backup: vip-coordinator-backup-2025-06-07-19-48-script-test]
This commit is contained in:
137
TESTING_QUICKSTART.md
Normal file
137
TESTING_QUICKSTART.md
Normal file
@@ -0,0 +1,137 @@
|
||||
# Testing Quick Start Guide
|
||||
|
||||
## 🚀 Get Testing in 5 Minutes
|
||||
|
||||
### 1. Prerequisites
|
||||
- Docker installed and running
|
||||
- Node.js 20+ (for local development)
|
||||
- Make command available
|
||||
|
||||
### 2. Initial Setup
|
||||
```bash
|
||||
# Clone and navigate to project
|
||||
cd vip-coordinator
|
||||
|
||||
# Copy environment variables
|
||||
cp .env.example .env
|
||||
|
||||
# Edit .env and add your values (or use defaults for testing)
|
||||
```
|
||||
|
||||
### 3. Run Your First Tests
|
||||
|
||||
#### Option A: Using Docker (Recommended)
|
||||
```bash
|
||||
# Run all tests
|
||||
make test
|
||||
|
||||
# Run specific test suites
|
||||
make test-backend # Backend only
|
||||
make test-frontend # Frontend only
|
||||
```
|
||||
|
||||
#### Option B: Local Development
|
||||
```bash
|
||||
# Backend tests
|
||||
cd backend
|
||||
npm install
|
||||
npm test
|
||||
|
||||
# Frontend tests
|
||||
cd ../frontend
|
||||
npm install
|
||||
npm test
|
||||
```
|
||||
|
||||
### 4. Writing Your First Test
|
||||
|
||||
#### Backend Test Example
|
||||
Create `backend/src/routes/__tests__/health.test.ts`:
|
||||
```typescript
|
||||
import request from 'supertest';
|
||||
import express from 'express';
|
||||
|
||||
const app = express();
|
||||
app.get('/health', (req, res) => res.json({ status: 'ok' }));
|
||||
|
||||
describe('Health Check', () => {
|
||||
it('should return status ok', async () => {
|
||||
const response = await request(app).get('/health');
|
||||
expect(response.status).toBe(200);
|
||||
expect(response.body.status).toBe('ok');
|
||||
});
|
||||
});
|
||||
```
|
||||
|
||||
#### Frontend Test Example
|
||||
Create `frontend/src/components/__tests__/Button.test.tsx`:
|
||||
```typescript
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import { Button } from '../Button';
|
||||
|
||||
describe('Button', () => {
|
||||
it('renders with text', () => {
|
||||
render(<Button>Click me</Button>);
|
||||
expect(screen.getByText('Click me')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
```
|
||||
|
||||
### 5. Common Commands
|
||||
|
||||
```bash
|
||||
# Database setup
|
||||
make db-setup # Initialize test database
|
||||
|
||||
# Run tests with coverage
|
||||
make test-coverage # Generate coverage reports
|
||||
|
||||
# Clean up
|
||||
make clean # Remove all test containers
|
||||
|
||||
# Get help
|
||||
make help # Show all available commands
|
||||
```
|
||||
|
||||
### 6. VS Code Integration
|
||||
|
||||
Add to `.vscode/settings.json`:
|
||||
```json
|
||||
{
|
||||
"jest.autoRun": {
|
||||
"watch": true,
|
||||
"onStartup": ["all-tests"]
|
||||
},
|
||||
"vitest.enable": true,
|
||||
"vitest.commandLine": "npm test"
|
||||
}
|
||||
```
|
||||
|
||||
### 7. Debugging Tests
|
||||
|
||||
```bash
|
||||
# Run specific test file
|
||||
npm test -- authService.test.ts
|
||||
|
||||
# Run in watch mode
|
||||
npm run test:watch
|
||||
|
||||
# Debug mode
|
||||
node --inspect-brk node_modules/.bin/jest --runInBand
|
||||
```
|
||||
|
||||
### 8. Tips
|
||||
|
||||
- ✅ Run tests before committing
|
||||
- ✅ Write tests for new features
|
||||
- ✅ Keep tests simple and focused
|
||||
- ✅ Use the provided fixtures and utilities
|
||||
- ✅ Check coverage reports regularly
|
||||
|
||||
### Need Help?
|
||||
|
||||
- See `TESTING.md` for detailed documentation
|
||||
- Check example tests in `__tests__` directories
|
||||
- Review `TESTING_SETUP_SUMMARY.md` for architecture overview
|
||||
|
||||
Happy Testing! 🎉
|
||||
Reference in New Issue
Block a user