Testing Pyramid
E2E
Integration
Unit
Unit Tests
Test individual functions/components
- ✅ Fast execution (ms)
- ✅ Isolated tests
- ✅ Most frequently written
Integration Tests
Test interactions between modules
- ✅ API endpoints
- ✅ DB integration
- ⚠️ Setup required
E2E Tests
Full user scenarios
- ✅ Real browser
- ⚠️ Slow execution (s)
- ⚠️ Keep to a minimum
Recommended ratio
Unit 70% · Integration 20% · E2E 10%
Choorai Project Test Status
| Project | API (Python) | API (Hono) | API (NestJS) | Web (React) | Web (Vue) |
|---|---|---|---|---|---|
| B2B Admin | 19 | 16 | 12 | 11 | 11 |
| B2C Todo | 23 | 19 | 13 | 12 | 5 |
| Total | 141 tests | ||||
Test Tools
Running Tests
Python (pytest)
Terminal
# B2B Admin API tests
cd examples/b2b-admin/api
pip install -r requirements.txt
pytest -v
# B2C Todo API tests
cd examples/b2c-todo/api
pytest -vNode.js (Vitest)
Terminal
# Hono API tests
cd examples/b2b-admin/api-hono
npm install
npm run test:run
# Vue frontend tests
cd examples/b2b-admin/web-vue
npm install
npm run test:runNestJS (Jest)
Terminal
# NestJS E2E tests
cd examples/b2b-admin/api-nest
npm install
npm run test:e2eCI/CD Integration
Choorai uses GitHub Actions to automatically run tests on every PR.
.github/workflows/ci.yml
# .github/workflows/ci.yml
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Python tests
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Run Python tests
run: |
cd examples/b2b-admin/api
pip install -r requirements.txt
pytest -v
# Node.js tests
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Run Hono tests
run: |
cd examples/b2b-admin/api-hono
npm ci
npm run test:runMerge only after all tests pass
All tests must pass before a PR can be merged. Check the execution status on GitHub Actions.
Next steps
Learn how to use pytest and Vitest in detail in the Unit Test Guide.
Write browser tests with Playwright in the E2E Test Guide.