Skip to content

Testing

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.py
Terminal window
make test
# or
pytest tests/
Terminal window
cd packages/ui
pnpm test # Vitest unit tests
pnpm test:watch # Watch mode
tests/unit/test_scheduler.py
import pytest
from 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 * * *"
tests/integration/test_api_projects.py
import httpx
import 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"

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:

  1. pytest tests/unit on Python 3.11, 3.12
  2. Linting (ruff check, mypy)
  3. TypeScript type checking (pnpm typecheck)