This document explains how to run tests for the Polari Suite project, covering both frontend (Angular) and backend (Python/Polari Framework) components.
The Polari Suite has three testing modes:
- Backend Isolation Testing - Tests only the Python backend framework
- Frontend Isolation Testing - Tests only the Angular frontend without backend
- Full-Stack Testing - Tests frontend and backend together with real API integration
cd polari-framework
docker-compose -f docker-compose.test.yml up --build --abort-on-container-exitThis will:
- Build the test Docker image
- Run all Python unit tests
- Display test results
- Exit when tests complete
Test results are displayed in the console output. Look for:
- Total tests run
- Number of successes
- Number of failures
- Number of errors
cd polari-platform-angular
docker-compose -f docker-compose.test.yml up --build --abort-on-container-exitThis will:
- Build the test Docker image with Chrome Headless
- Run Karma/Jasmine tests without connecting to backend
- Generate code coverage report
- Exit when tests complete
- Test results are displayed in the console
- Coverage reports are generated in
polari-platform-angular/coverage/ - Open
coverage/polari-platform/index.htmlin a browser to view detailed coverage
From the polari-node directory:
docker-compose -f docker-compose.fullstack-test.yml up --build --abort-on-container-exitThis will:
- Backend Tests: Run backend tests first
- Backend Server: Start backend server if tests pass
- Frontend Tests: Run frontend tests with real API calls to backend
- Exit when all tests complete
- Backend tests must pass before server starts
- Server must be healthy before frontend tests run
- Frontend tests run in
fullstackmode withBACKEND_URLset - All containers exit when tests complete
TEST_MODE- Set toisolation(default) orfullstackBACKEND_URL- Backend API URL (used in fullstack mode)
No special environment variables needed for basic testing.
polari-framework/Dockerfile.test- Backend test containerpolari-framework/docker-compose.test.yml- Backend test orchestrationpolari-framework/run_tests.py- Python test runnerpolari-framework/tests/- Test files
polari-platform-angular/Dockerfile.test- Frontend test containerpolari-platform-angular/docker-compose.test.yml- Frontend test orchestrationpolari-platform-angular/karma.conf.js- Karma test configurationpolari-platform-angular/src/**/*.spec.ts- Test files
docker-compose.fullstack-test.yml- Orchestrates both test suites
cd polari-framework
python run_tests.pycd polari-platform-angular
npm testFor CI/CD pipelines, use:
# Backend only
docker-compose -f polari-framework/docker-compose.test.yml up --build --abort-on-container-exit
# Frontend only
docker-compose -f polari-platform-angular/docker-compose.test.yml up --build --abort-on-container-exit
# Full-stack
docker-compose -f docker-compose.fullstack-test.yml up --build --abort-on-container-exitAll commands exit with appropriate status codes for CI integration.
- Check Python dependencies are installed correctly
- Verify database connections if tests use database
- Check test output for specific error messages
- Ensure Chrome is available in the container
- Check karma.conf.js configuration
- Verify all Angular dependencies are installed
- Look for test-specific errors in console output
- Ensure backend tests pass first
- Check backend server starts successfully (health check)
- Verify network connectivity between containers
- Check
BACKEND_URLis correctly set for frontend
Coverage reports can be added to the backend by modifying run_tests.py to use coverage tools like pytest-cov.
Frontend coverage is automatically generated in polari-platform-angular/coverage/:
- HTML reports:
coverage/polari-platform/index.html - Text summary: Displayed in console output
Add test files in polari-framework/tests/ following the pattern test_*.py.
Add test files alongside components following the pattern *.spec.ts.
- Isolation Tests: Use mocks and stubs for external dependencies
- Full-Stack Tests: Test real API integration and end-to-end flows
- Keep Tests Fast: Isolation tests should run quickly
- Clear Test Names: Use descriptive test names that explain what is being tested