Skip to content

Latest commit

 

History

History
157 lines (117 loc) · 3.1 KB

File metadata and controls

157 lines (117 loc) · 3.1 KB

Testing Guide

This document describes how to run tests for all components of the tasks project.

Quick Test Commands

Backend Tests

cd backend
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
pip install -r requirements.txt
pytest tests/unit -v
pytest tests/integration -v
pytest tests/ -v  # Run all tests

Frontend Linting

cd web
npm install
npm run lint

E2E Tests

cd tests
npm install
npx playwright install chromium
npx playwright test

All Linting

# Backend
cd backend
ruff check .

# Simulator
cd simulator
ruff check .

# Frontend
cd web
npm run lint

Running GitHub Actions Locally

Use act to run GitHub Actions workflows locally.

Installation

macOS:

brew install act

Linux:

# Download from https://github.com/nektos/act/releases
# Or use package manager if available

Prerequisites:

  • Docker must be installed and running

Usage

# List all workflows
act -l

# Run all workflows
act

# Run specific workflow file
act -W .github/workflows/tests.yml

# Run one job
act -j frontend -W .github/workflows/tests.yml
act -j e2e-tests -W .github/workflows/tests.yml

# Run on specific event
act push
act pull_request

Troubleshooting

  • If Docker images fail: act --pull=false
  • For verbose output: act -v
  • To use secrets: Create .secrets file and use act --secret-file .secrets

See .github/workflows/README.md for more details.

CI/CD Pipeline

The GitHub Actions workflow (.github/workflows/tests.yml) runs:

  1. Lint — Ruff (backend, simulator), ESLint + typecheck (frontend)
  2. Frontend checks — translation keys, Vitest unit tests
  3. Backend tests — unit and integration tests across Python 3.11, 3.12, 3.13
  4. E2E tests — Playwright end-to-end tests

All checks run automatically on push and pull requests to main or develop. Use the ci job as the required status check for branch protection.

Path-filtered workflows also run separately:

  • build-web.yml — Next.js production build when web/** changes
  • lint-dockerfiles.yml — Dockerfile lint when Dockerfiles change
  • docker-build.yml — GHCR image builds on main and relevant PRs

Test Structure

backend/
  tests/
    unit/          # Unit tests for services and utilities
    integration/    # Integration tests for resolvers
    conftest.py     # Shared test fixtures

tests/
  e2e/             # End-to-end Playwright tests
    *.spec.ts      # Test specifications
    playwright.config.ts
  package.json     # E2E test dependencies

Fixing Common Issues

npm ci Error (EUSAGE)

If you see npm ci errors about lock file sync:

cd web  # or tests
rm -rf node_modules package-lock.json
npm install

Playwright Browser Not Found

cd tests
npx playwright install chromium

Python Module Not Found

Ensure you're in a virtual environment with dependencies installed:

cd backend
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt