A production-grade e-commerce platform API with 500+ tests, demonstrating CircleCI's adaptive testing capabilities and optimization techniques for large test suites.
This codebase serves as a comprehensive example for:
- Test-Driven Development (TDD) - All features built with tests first
- CircleCI Adaptive Testing - Intelligent test selection and parallel execution
- Production-Grade Architecture - Real-world microservices patterns
- Comprehensive Testing Strategy - Unit, integration, E2E, and performance tests
| Category | Count | Description |
|---|---|---|
| Unit Tests | ~350 | Service logic, entities, repositories, utilities |
| Integration Tests | ~120 | Database operations, service communication, auth flows |
| E2E Tests | ~80 | REST endpoints, GraphQL resolvers, complete workflows |
| Performance Tests | ~20 | Load testing, query optimization, response validation |
| TOTAL | ~570 | Comprehensive coverage |
src/
βββ services/
β βββ user-management/ # Authentication, user profiles, roles
β βββ product-catalog/ # Products, inventory, search
β βββ order-processing/ # Orders, cart, checkout, payments
β βββ notifications/ # Email, SMS, webhooks
β βββ analytics/ # Sales metrics, reporting
βββ libs/ # Shared libraries
β βββ auth/ # JWT, password utilities, middleware
β βββ database/ # TypeORM configuration, base repository
β βββ errors/ # Custom error classes
β βββ logger/ # Winston logging
β βββ validation/ # Zod schemas, validators
βββ tests/ # Integration, E2E, performance tests
- Language: TypeScript 5.3+
- Runtime: Node.js 18+
- Framework: Express.js / Fastify
- Database: PostgreSQL 15+ with TypeORM
- Cache: Redis 7+
- Testing: Jest with ts-jest
- API Styles: REST + GraphQL (Apollo Server)
- Validation: Zod
- CI/CD: CircleCI with Adaptive Testing
- Node.js >= 18.0.0
- PostgreSQL >= 15.0
- Redis >= 7.0
- npm >= 9.0.0
# Clone the repository
git clone <repository-url>
cd ecommerce-adaptive-testing
# Install dependencies
npm install
# Copy environment variables
cp .env.example .env
# Edit .env with your database credentials# Start PostgreSQL and Redis (using Docker)
docker-compose up -d
# Run migrations
npm run db:migrate
# Seed test data
npm run db:seed# Run all tests
npm test
# Run specific test suites
npm run test:unit
npm run test:integration
npm run test:e2e
npm run test:performance
# Run tests with coverage
npm run test:coverage
# Run tests in watch mode
npm run test:watch
# Run tests for CI
npm run test:ci# Start development server
npm run dev
# Build for production
npm run build
# Start production server
npm start
# Lint code
npm run lint
# Format code
npm run formatAll features in this codebase were built following strict TDD:
- RED - Write failing test first
- GREEN - Write minimal code to pass
- REFACTOR - Improve code while keeping tests green
See docs/TDD-PROCESS.md for detailed examples.
Adaptive_Testing/
βββ src/
β βββ services/
β β βββ user-management/
β β β βββ entities/
β β β β βββ user.entity.ts
β β β β βββ user.entity.spec.ts # Entity unit tests
β β β βββ repositories/
β β β β βββ user.repository.ts
β β β β βββ user.repository.spec.ts # Repository unit tests
β β β βββ services/
β β β βββ user.service.ts
β β β βββ user.service.spec.ts # Service unit tests
β β βββ [other services...]
β βββ libs/
β βββ [shared libraries with *.spec.ts]
βββ tests/
β βββ integration/ # Integration tests
β β βββ database/
β β βββ services/
β β βββ external/
β β βββ auth/
β βββ e2e/ # End-to-end tests
β β βββ rest/
β β βββ graphql/
β β βββ workflows/
β βββ performance/ # Performance tests
β βββ load/
β βββ database/
- Intelligent Test Selection - Only runs tests affected by code changes
- Parallel Execution - Splits tests across multiple nodes
- Timing-Based Optimization - Balances test distribution by execution time
- Flaky Test Detection - Automatically retries and quarantines unstable tests
.circleci/config.yml- Main CircleCI workflow configuration.circleci/test-suites.yml- Test suite organization and adaptive testing rules
- Runs on
mainbranch - Sequential test execution
- Full test suite every time
- Purpose: Performance baseline for comparison
- Runs on feature branches
- Parallel test execution (4 nodes for unit tests)
- Intelligent test selection based on changes
- Purpose: Optimized CI/CD pipeline
- Runs daily at midnight UTC
- Comprehensive test coverage
- Performance benchmarking
- Purpose: Catch integration issues
| Metric | Baseline | Adaptive Testing | Improvement |
|---|---|---|---|
| Avg Duration | ~15 min | ~4 min | 73% faster |
| Resource Usage | 1 node | 4 nodes | Better utilization |
| Tests Run | 570 | ~150-300 | Context-aware |
| Cost per Build | $0.50 | $0.30 | 40% reduction |
See docs/METRICS.md for detailed performance analysis.
Coverage thresholds are enforced at 80% for:
- Statements
- Branches
- Functions
- Lines
Current coverage: ~85%
# Generate coverage report
npm run test:coverage
# View coverage report
open coverage/lcov-report/index.html# Run ESLint
npm run lint
# Auto-fix issues
npm run lint:fix# TypeScript strict mode enabled
npm run typecheck# Check formatting
npm run format:check
# Auto-format
npm run format- TDD-PROCESS.md - Detailed TDD cycles with examples
- TEST-SCENARIOS.md - Adaptive testing demonstration scenarios
- METRICS.md - Performance benchmarks and comparisons
- TROUBLESHOOTING.md - Common issues and solutions
With 500+ tests:
- Traditional CI: Every commit runs all tests (~15 minutes)
- Adaptive Testing: Runs only affected tests (~4 minutes)
- Impact: 73% reduction in CI time, faster feedback loops
β Good Fit:
- Large test suites (200+ tests)
- Microservices architecture
- Frequent commits
- Multiple developers
β Not Necessary:
- Small projects (<100 tests)
- Monolithic apps with tightly coupled code
- Infrequent deployments
- Organize Tests Logically - Group by feature/service
- Maintain Test Independence - No shared state between tests
- Tag Tests Appropriately - Enable smart filtering
- Monitor Flaky Tests - Fix or quarantine unstable tests
- Use Parallel Execution - Balance nodes by test timing
This is a demonstration project, but contributions for improvements are welcome:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Write tests first (TDD)
- Implement the feature
- Ensure all tests pass
- Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open a Pull Request
MIT License - See LICENSE file for details
- Built to demonstrate CircleCI's adaptive testing capabilities
- Follows production-grade best practices from real-world e-commerce platforms
- All code written with strict TDD methodology
For questions or issues:
- CircleCI Documentation: https://circleci.com/docs/
- Project Issues: GitHub Issues
- Discussion: GitHub Discussions
Note: This is a demonstration project. For production use, add:
- Authentication secrets management (e.g., Vault)
- API rate limiting implementation
- Comprehensive API documentation (OpenAPI/Swagger)
- Monitoring and observability (DataDog, NewRelic)
- Container orchestration (Kubernetes)