Testing
Test structure
Section titled “Test structure”tests/├── unit/ # Fast, isolated unit tests│ ├── test_trust.py│ ├── test_scheduler.py│ ├── test_executor.py│ └── ...├── integration/ # Tests that require a running daemon│ ├── test_api_auth.py│ ├── test_api_projects.py│ └── ...└── e2e/ # End-to-end browser tests └── test_ui_flows.pyRunning tests
Section titled “Running tests”make test# orpytest tests/make test-unit# orpytest tests/unit -vmake test-integration# Requires daemon running on port 18781snippbot start --devpytest tests/integration -vmake test-cov# Generates htmlcov/ reportopen htmlcov/index.htmlFrontend tests
Section titled “Frontend tests”cd packages/uipnpm test # Vitest unit testspnpm test:watch # Watch modeWriting tests
Section titled “Writing tests”Python unit tests
Section titled “Python unit tests”import pytestfrom snippbot_core.scheduler import ScheduleParser
def test_parse_cron(): result = ScheduleParser.parse("0 9 * * 1-5") assert result.type == "cron" assert result.expression == "0 9 * * 1-5"
def test_parse_natural_language(): result = ScheduleParser.parse("every day at 9am") assert result.type == "cron" assert result.expression == "0 9 * * *"Integration tests
Section titled “Integration tests”import httpximport pytest
BASE = "http://localhost:18781"HEADERS = {"Authorization": "Bearer snip_test_key"}
def test_create_project(): resp = httpx.post(f"{BASE}/api/projects", json={"goal": "Test project"}, headers=HEADERS) assert resp.status_code == 200 assert resp.json()["status"] == "pending"Test configuration
Section titled “Test configuration”Tests use pytest. Configuration is in pyproject.toml:
[tool.pytest.ini_options]testpaths = ["tests"]asyncio_mode = "auto"Tests run automatically on every pull request via GitHub Actions. The CI matrix runs:
pytest tests/uniton Python 3.11, 3.12- Linting (
ruff check,mypy) - TypeScript type checking (
pnpm typecheck)