This directory contains the comprehensive testing framework for the Pokemon Card Price Checker (PCPC) project, implementing enterprise-grade testing practices following the Test Pyramid pattern.
/\
/ \ E2E Tests (Few, High Value)
/____\ - Playwright browser automation
/ \ - Critical user journeys
/________\ - Cross-browser compatibility
/ \ Integration Tests (Some)
/____________\ - API integration testing
- Database integration
- Service integration
Unit Tests (Many, Fast)
- Jest for frontend/backend
- High coverage, isolated
- Fast feedback loop
tests/
├── README.md # This file - testing framework overview
├── config/ # Shared testing configurations
│ ├── jest.config.js # Jest configuration for unit tests
│ ├── playwright.config.ts # Playwright configuration for E2E tests
│ ├── test-setup.js # Global test setup and utilities
│ └── test-helpers.js # Shared testing helper functions
├── frontend/ # Frontend testing suite
│ ├── components/ # Svelte component unit tests
│ ├── services/ # Service layer unit tests
│ ├── stores/ # Store unit tests
│ ├── integration/ # Frontend integration tests
│ └── __mocks__/ # Frontend mocks and fixtures
├── backend/ # Backend testing suite
│ ├── functions/ # Azure Functions unit tests
│ ├── services/ # Service layer unit tests
│ ├── utils/ # Utility function tests
│ ├── integration/ # Backend integration tests
│ ├── contracts/ # API contract tests
│ └── __mocks__/ # Backend mocks and fixtures
├── e2e/ # End-to-end testing suite
│ ├── frontend/ # Frontend E2E tests
│ ├── api/ # API E2E tests
│ ├── fixtures/ # Test data and fixtures
│ └── page-objects/ # Page object models
├── infrastructure/ # Infrastructure testing suite
│ ├── modules/ # Terraform module tests
│ ├── environments/ # Environment deployment tests
│ ├── integration/ # Infrastructure integration tests
│ └── security/ # Security and compliance tests
├── performance/ # Performance testing suite
│ ├── load/ # Load testing scripts (K6)
│ ├── stress/ # Stress testing scenarios
│ ├── benchmarks/ # Performance benchmarks
│ └── reports/ # Performance test reports
└── security/ # Security testing suite
├── vulnerability/ # Vulnerability scanning
├── compliance/ # Compliance testing
└── penetration/ # Penetration testing scripts
- Jest: JavaScript/TypeScript unit testing framework
- @testing-library/svelte: Svelte component testing utilities
- @testing-library/jest-dom: Custom Jest matchers for DOM testing
- Supertest: HTTP assertion library for API testing
- @azure/cosmos: Cosmos DB integration testing
- testcontainers: Container-based integration testing
- Playwright: Modern browser automation framework
- @playwright/test: Playwright test runner
- Cross-browser testing (Chrome, Firefox, Safari)
- Terratest: Go-based infrastructure testing framework
- Azure SDK: Azure resource validation
- Checkov: Infrastructure security scanning
- K6: Modern load testing framework
- Artillery: Alternative load testing tool
- Lighthouse CI: Performance auditing
- npm audit: Dependency vulnerability scanning
- Snyk: Security vulnerability detection
- OWASP ZAP: Security testing proxy
# Run all test suites
make test
# Run tests with coverage
make test-coverage
# Run tests in watch mode
make test-watch# Frontend unit tests
npm run test:frontend
# Backend unit tests
npm run test:backend
# Specific test file
npm test -- tests/frontend/components/SearchableSelect.test.js# Frontend integration tests
npm run test:frontend:integration
# Backend integration tests
npm run test:backend:integration
# Infrastructure tests
npm run test:infrastructure# All E2E tests
npm run test:e2e
# Specific browser
npm run test:e2e -- --project=chromium
# Headed mode (visible browser)
npm run test:e2e -- --headed# Load tests
npm run test:performance
# Specific load test
k6 run tests/performance/load/api-endpoints.js# Security scan
npm run test:security
# Vulnerability scan
npm audit- Test data stored in
fixtures/directories - JSON files for API responses
- Mock data for database operations
- Sample files for file upload testing
- Service mocks in
__mocks__/directories - External API mocks
- Database operation mocks
- File system operation mocks
# .github/workflows/test.yml
- name: Run Tests
run: |
npm run test:unit
npm run test:integration
npm run test:e2e
npm run test:security- Jest coverage reports
- Playwright HTML reports
- Performance test results
- Security scan reports
- Test one thing at a time
- Use descriptive test names
- Follow AAA pattern (Arrange, Act, Assert)
- Mock external dependencies
- Aim for high coverage (>80%)
- Test real interactions between components
- Use test databases/containers
- Clean up after each test
- Test error scenarios
- Focus on critical user journeys
- Use page object models
- Keep tests independent
- Test across different browsers
- Establish baseline metrics
- Test under realistic load
- Monitor resource usage
- Set performance budgets
- Regular vulnerability scanning
- Test authentication/authorization
- Validate input sanitization
- Check for common vulnerabilities
- Unit Tests: >90% code coverage
- Integration Tests: >80% API endpoint coverage
- E2E Tests: 100% critical user journey coverage
- Performance Tests: All public endpoints tested
- Security Tests: All attack vectors covered
- Test timeouts: Increase timeout values in configuration
- Flaky tests: Add proper waits and assertions
- Mock issues: Verify mock implementations match real services
- Environment issues: Ensure test environment is properly configured
# Debug Jest tests
npm run test:debug
# Debug Playwright tests
npm run test:e2e:debug
# Verbose output
npm test -- --verbose- Follow existing naming conventions
- Add tests to appropriate directory
- Update this README if adding new test types
- Ensure tests pass in CI/CD pipeline
- Unit tests:
ComponentName.test.js - Integration tests:
ServiceName.integration.test.js - E2E tests:
user-journey-name.e2e.test.js - Performance tests:
endpoint-name.load.test.js
This testing framework ensures comprehensive coverage across all layers of the PCPC application, providing confidence in code quality, performance, and security.