Documentation Index
Fetch the complete documentation index at: https://docs.pyqdeck.in/llms.txt
Use this file to discover all available pages before exploring further.
Overview
PyqDeck uses a pragmatic testing strategy: unit tests for backend logic and component tests for UI. We prioritize tests that give the most confidence with the least maintenance burden.Testing Stack
| Layer | Tool | Purpose |
|---|---|---|
| Backend Unit/Integration | Vitest | Services, repositories, controllers, middleware |
| Backend Load Testing | k6 | API performance and stress testing |
| Frontend Components | Vitest + Storybook | UI component testing |
| E2E (future) | Playwright | Full user journey testing |
When to Write What
Backend Tests (Vitest)
Write Vitest tests for:- Services - Business logic (e.g., paper parsing, question extraction)
- Repositories - Database queries and aggregations
- Controllers - Request/response handling, validation
- Middleware - Auth, pagination, rate limiting, error handling
- Utilities - Formatters, validators, error classes
Load Tests (k6)
Write k6 tests for:- Critical paths -
/papers,/questions,/search - Before major releases - Verify performance hasn’t degraded
- After database changes - Ensure query performance is acceptable
Frontend Tests (Storybook + Vitest)
Write component tests for:- Complex UI components - Those with multiple states (loading, error, empty)
- Interactive components - Forms, filters, modals
- Accessibility-critical components - Navigation, forms, modals
Backend Testing Guide
Test Structure
Tests live inbackend/tests/ mirroring the source structure:
Example: Service Test
Running Tests
Coverage Thresholds
The project enforces minimum coverage:| Metric | Threshold |
|---|---|
| Lines | 80% |
| Functions | 80% |
| Statements | 80% |
| Branches | 70% |
Load Testing Guide
Running Load Tests
Smoke Test Example
Frontend Testing Guide
Component Testing with Storybook
Each UI component has a matching Storybook story:Running Frontend Tests
CI Integration
All tests run in CI on every PR:- Backend tests - Vitest with coverage thresholds
- Contract check - Verifies
openapi.jsonis in sync - Frontend build - Validates SDK generation and Next.js build
- Load tests - Run against a live MongoDB service
Anti-Patterns to Avoid
- Don’t test implementation details - Test behavior, not internal state
- Don’t mock everything - Use real MongoDB (via MongoMemoryServer) when possible
- Don’t skip error path tests - Test failure cases as thoroughly as success cases
- Don’t write E2E tests for everything - Reserve E2E for critical user journeys only
Next Steps
- Read about the SDK flow
- Explore the monorepo architecture
- Check the deployment pipeline

