-
Notifications
You must be signed in to change notification settings - Fork 0
TESTING
scheilch edited this page Mar 8, 2026
·
1 revision
Professional npm-based test orchestration for the OpenCloudTouch monorepo.
# Install dependencies (root + all workspaces)
npm install
# Run all tests
npm test
# Run specific test suites
npm run test:backend # Python pytest
npm run test:frontend # Vitest unit tests
npm run test:e2e # Cypress E2E tests# All tests (Backend → Frontend → E2E)
npm test
# or
npm run test:allnpm run test:backend
# Direct pytest (from apps/backend)
cd apps/backend
pytest -v --cov=srcnpm run test:frontend
# Watch mode
npm run test:frontend -- --watch
# Coverage
npm run test:frontend -- --coverage# Automated run (headless)
npm run test:e2e
# Interactive mode
cd apps/frontend
npm run test:e2e:open
# Headed mode (see browser but automated)
cd apps/frontend
npm run test:e2e:headed# Start both backend and frontend
npm run dev
# Build frontend
npm run build
# Preview production build
npm run preview# Clean all build artifacts and dependencies
npm run clean# Build Docker image
docker build -t opencloudtouch:latest .
# Run Docker container
docker run --rm -p 7777:7777 opencloudtouch:latestopencloudtouch/
├── package.json # Root workspace orchestration
├── scripts/
│ └── e2e-runner.mjs # Node.js E2E test runner
├── apps/
│ ├── backend/ # Python FastAPI backend
│ │ ├── pyproject.toml
│ │ ├── pytest.ini
│ │ └── src/opencloudtouch/
│ └── frontend/ # React frontend
│ ├── package.json # Workspace package
│ ├── vite.config.js
│ ├── vitest.config.js
│ └── cypress.config.js
└── tools/
└── local-scripts/ # Legacy PowerShell scripts (deprecated)
The scripts/e2e-runner.mjs script orchestrates E2E tests:
- Cleanup - Kill processes on ports 7778 (backend) and 4173 (frontend)
- Start Backend - Launch FastAPI on port 7778 with mock mode
- Build Frontend - Production build via Vite
- Start Preview - Vite preview server on port 4173
- Run Cypress - Execute E2E tests
- Cleanup - Stop all processes and free ports
Why Node.js instead of PowerShell?
- ✅ Cross-platform (Windows, macOS, Linux)
- ✅ Better error handling and async control
- ✅ Integrates seamlessly with npm scripts
- ✅ No shell-specific issues (encoding, pipes, exit codes)
- ✅ Professional industry standard
.\tools\local-scripts\run-all-tests.ps1
.\tools\local-scripts\run-e2e-tests.ps1 -MockMode $trueProblems:
- Platform-specific (Windows only)
- Encoding issues (UTF-8, emojis)
- Exit code bugs (Cypress -1)
- Complex script orchestration
- Hard to debug hanging processes
npm test # All tests
npm run test:e2e # E2E onlyBenefits:
- Cross-platform
- Industry standard
- Clean exit codes
- Proper async/await
- Better error messages
- Integrated with IDE
name: Tests
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
run: |
npm install
cd apps/backend && pip install -r requirements.txt
- name: Run tests
run: npm testtest:
image: node:20
before_script:
- npm install
- cd apps/backend && pip install -r requirements.txt
script:
- npm testSymptom: Tests never start or hang at "Running Cypress..."
Solution:
# Kill stuck processes
npx kill-port 7778 4173
# Or manually
# Windows
netstat -ano | findstr :7778
taskkill /F /PID <PID>
# Linux/macOS
lsof -ti:7778 | xargs kill -9Symptom: Vite build errors
Solution:
cd apps/frontend
rm -rf node_modules dist
npm install
npm run buildSymptom: Import errors or module not found
Solution:
cd apps/backend
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -r requirements.txt -r requirements-dev.txt
pytest -v- Always use npm scripts (not direct CLI commands)
-
Run tests before commit (
npm test) -
Use watch mode during development (
npm run test:frontend -- --watch) -
Open E2E UI for debugging (
cd apps/frontend && npm run test:e2e:open)
-
Use
npm testfor sequential execution -
Cache dependencies (
node_modules,.venv) - Fail fast - stop on first failure
- Upload coverage reports
- Archive test artifacts (screenshots, videos)
- Backend Tests: ~8-15s (291 tests, 92% coverage)
- Frontend Tests: ~3-8s (197 tests)
- E2E Tests: ~30-45s (15 tests, 2 specs)
- Total: ~45-70s
- Run tests individually during development for faster feedback
- Skip E2E in pre-commit (too slow): only run backend + frontend unit
- Use Vite watch mode during frontend development
- Run E2E headed mode for debugging (see what's happening)
Track test coverage over time with automated PR comments showing coverage changes.
- Create Codecov account: https://about.codecov.io/ → Sign in with GitHub
-
Activate repository: Find
soundtouch-bridgein Codecov dashboard → Enable -
Add GitHub Secret: Copy upload token from Codecov → Add as
CODECOV_TOKENin GitHub repo secrets - Verify: Push a commit → Check GitHub Actions → Codecov upload should succeed
- 📊 Coverage trends over time
- 🔍 PR comments showing coverage diff for changed files
⚠️ Automatic warnings if coverage drops- 📁 File-level coverage browser
Optional codecov.yml in project root:
coverage:
status:
project:
default:
target: 80% # Minimum coverage threshold
threshold: 1% # Max 1% drop allowedBadge: Add to README:
[](https://codecov.io/gh/user/soundtouch-bridge)Cost: Free for public repositories
Docs: https://docs.codecov.com/
- Test result caching (Nx, Turborepo)
- Visual regression testing (Percy, Chromatic)
- Performance budgets (Lighthouse CI)
- Contract testing (Pact)
- Mutation testing (Stryker)
- Test parallelization (Cypress Cloud)
Questions? Check the main README or open an issue.
🇩🇪 Benutzerhandbuch
🇬🇧 User Guide
Development
API & Architecture
- REST API
- ADR 001 Clean Architecture
- ADR 002 FastAPI App State
- ADR 003 SSDP Discovery
- ADR 004 React/TS/Vite
Technical Reference
Legal