This guide provides comprehensive instructions for running end-to-end tests for the New Tab Chrome Extension and Backend.
- Python 3.11+ with
uvpackage manager - Node.js 18+ (for extension development)
- Chrome/Chromium browser (for extension testing)
# Navigate to backend directory
cd backend
# Install dependencies using uv
uv install
# Install Playwright browsers (required for e2e tests)
uv run playwright install chromium| File | Purpose | Type | Status |
|---|---|---|---|
backend/tests/test_e2e_playwright.py |
Backend API E2E tests | E2E | ✅ Active |
backend/tests/test_e2e_extension.py |
Extension + Backend integration | E2E | ✅ Active |
backend/tests/test_simple_backend.py |
Simple backend API tests | Integration | ✅ Active |
backend/tests/test_integration_api.py |
Comprehensive API integration | Integration | ✅ Active |
backend/tests/test_query_cache.py |
Cache functionality tests | Unit | ✅ Active |
backend/tests/test_performance.py |
Performance benchmarks | Performance | ✅ Active |
test/comprehensive_ui_test.py→ Usebackend/tests/test_e2e_extension.pytest/simple_extension_test.py→ Usebackend/tests/test_e2e_extension.pytest/test_extension_playwright.py→ Usebackend/tests/test_e2e_extension.py
cd backend
uv run pytest tests/test_simple_backend.py -vDuration: ~10 seconds
Purpose: Quick smoke tests for API endpoints
cd backend
uv run pytest tests/test_integration_api.py -vDuration: ~30 seconds
Purpose: Comprehensive API testing with mocks
cd backend
uv run pytest tests/test_e2e_playwright.py -vDuration: ~60 seconds
Purpose: Full backend API testing with real server
cd backend
uv run pytest tests/test_e2e_extension.py -vDuration: ~120 seconds
Purpose: Extension + Backend integration testing
Requirements: Display available (not headless)
cd backend
uv run pytest tests/test_performance.py -vDuration: ~90 seconds
Purpose: Performance benchmarking
cd backend
uv run pytest -vDuration: ~5 minutes
Purpose: Complete test suite
uv run pytest -m unit -v- Fast, isolated tests
- No external dependencies
- Test individual components
uv run pytest -m integration -v- Test component interactions
- May use mocks for external services
- Database and API testing
uv run pytest -m e2e -v- Full system testing
- Real browsers and servers
- Complete user workflows
uv run pytest -m performance -v- Performance benchmarking
- Load testing
- Memory usage analysis
Tests are categorized using pytest markers:
@pytest.mark.unit # Unit tests
@pytest.mark.integration # Integration tests
@pytest.mark.e2e # End-to-end tests
@pytest.mark.performance # Performance tests
@pytest.mark.slow # Slow running tests# Optional: Set custom test server port
export TEST_SERVER_PORT=8001
# Optional: Enable verbose logging
export TEST_LOG_LEVEL=DEBUG
# Optional: Skip browser-based tests
export SKIP_BROWSER_TESTS=trueThe tests automatically start a test server, but you can also run it manually:
cd backend
uv run python -m src.mainServer will be available at http://localhost:8000
# Reinstall Playwright browsers
uv run playwright install --force chromium# Check extension path
ls -la extension/manifest.json
# Verify extension structure
tree extension/# Check if port is in use
lsof -i :8000
lsof -i :8001
# Kill processes if needed
pkill -f uvicorn# Fix permissions for test files
chmod +x backend/scripts/*.sh# For headless environments, skip extension tests
export SKIP_BROWSER_TESTS=true
uv run pytest tests/test_simple_backend.py tests/test_integration_api.py -vuv run pytest tests/test_e2e_extension.py::TestExtensionBasicFunctionality::test_extension_loads_new_tab -v -suv run pytest tests/test_e2e_extension.py -v -s --tb=longcd backend
uv run python tests/test_e2e_extension.py --manualThis opens a browser window for manual inspection.
cd backend
uv run pytest --cov=src --cov-report=html tests/View coverage report: backend/htmlcov/index.html
- Unit Tests: >90% coverage
- Integration Tests: >80% coverage
- E2E Tests: >70% coverage
The project includes CI/CD configuration:
# .github/workflows/ci.yml
- name: Run Backend Tests
run: |
cd backend
uv run pytest tests/test_simple_backend.py tests/test_integration_api.py -v# Install pre-commit hooks
pre-commit install
# Run all tests before commit
uv run pytest tests/test_simple_backend.py tests/test_integration_api.py| Test Suite | Duration | Memory Usage |
|---|---|---|
| Simple Backend | <10s | <50MB |
| Integration | <30s | <100MB |
| Backend E2E | <60s | <150MB |
| Extension E2E | <120s | <200MB |
| Performance | <90s | <100MB |
# Run performance benchmarks
uv run pytest tests/test_performance.py -v
# Profile memory usage
uv run pytest tests/test_performance.py --profile-svg# Install pytest-watch
uv add --dev pytest-watch
# Run tests in watch mode
uv run ptw tests/test_simple_backend.py# Run tests every 30 minutes
while true; do
uv run pytest tests/test_simple_backend.py
sleep 1800
doneTests use predefined sample data:
# Sample page data
sample_page = {
"url": "https://example.com/test",
"title": "Test Page",
"content": "Test content",
"metadata": {"test": True}
}Common test fixtures are available in backend/tests/conftest.py:
client: FastAPI test clientmock_ark_client: Mocked API clientsample_page_data: Sample page datatest_server: Running test server
Create backend/pytest.local.ini:
[tool:pytest]
testpaths = tests
markers =
custom: Custom test marker
addopts =
--strict-markers
--maxfail=5
--tb=shortCreate test data files in backend/tests/data/:
mkdir -p backend/tests/data
echo '{"test": "data"}' > backend/tests/data/sample.json- ✅
test_simple_backend.py- Must pass - ✅
test_integration_api.py- Must pass ⚠️ test_e2e_playwright.py- Should pass⚠️ test_e2e_extension.py- Optional (requires display)
cd backend && uv run pytest tests/test_simple_backend.py tests/test_integration_api.py tests/test_e2e_playwright.py -vIf you encounter issues with testing:
- Check this guide first
- Look at existing test files for examples
- Check the troubleshooting section
- Create an issue with test output and environment details
Happy Testing! 🧪✨