CyberAg Documentation

Testing Guide

CyberAg uses a three-layer test pyramid: **Vitest** (unit/integration), **Storybook** (visual + interaction), and **Playwright** (E2E).

Quick start


# All unit tests (Turbo fan-out)
npm test

# UI component tests only
npm run test --workspace=@cyberag/ui

# Storybook (manual + interaction stories)
npm run storybook

# E2E (requires Docker + LocalStack)
npm run test:e2e

# Everything
npm run test:all

Prerequisites

LayerRequirements
VitestNode 20+, npm ci
StorybookNone beyond install
E2EDocker, LocalStack on port 4566, seeded data

Local E2E setup


# Start LocalStack + deploy + seed
export GEMINI_API_KEY=your-key   # or set a dummy key for non-AI flows
npm run local:up
npm run local:deploy
npm run local:seed

# Run E2E (starts console on :3002 automatically)
npm run test:e2e

Skip infra when already running:


E2E_SKIP_SETUP=1 npm run test:e2e

Package coverage

WorkspaceRunnerLocation
@cyberag/uiVitest + RTL + vitest-axepackages/ui/src/**/*.test.tsx
@cyberag/sdkVitestpackages/sdk/src/index.test.ts
@cyberag/platform-authVitestpackages/platform-auth/src/index.test.ts
@cyberag/detection-coreVitestpackages/detection-core/test/
@cyberag/guardrail-coreVitestpackages/guardrail-core/src/index.test.ts
@cyberag/wrapsec-adapterVitestpackages/wrapsec-adapter/test/
@cyberag/apiVitestservices/api/src/router.test.ts
@cyberag/evalVitestservices/eval/src/parse.test.ts
@cyberag/guardrail-gatewayVitest smokeservices/guardrail-gateway/src/handler.test.ts
@cyberag/replayVitest smokeservices/replay/src/handler.test.ts
@cyberag/connectorsVitest smokeservices/connectors/src/handler.test.ts
@cyberag/e2ePlaywrighte2e/tests/
Python SDKpytestintegrations/python/tests/

UI component conventions

  • Colocate tests: Button.tsxButton.test.tsx
  • Use render from packages/ui/src/test/render.tsx
  • Assert behavior + accessibility (getByRole, vitest-axe for interactive primitives)
  • Mock heavy deps (recharts, @xyflow/react) in domain tests
  • CI matrix

    JobCommandTrigger
    buildnpm run build && npm run lint && npm run testevery PR
    build (storybook)npm run build-storybook --workspace=@cyberag/uievery PR
    python-testspytest integrations/python/testsevery PR
    e2ePlaywright P0 specs + DockerPR + main
    e2e-aiPlaywright AI specsnightly / manual

    E2E spec map

    SpecFlow
    p0-navigationAll 18 console routes render
    p0-kill-switchActivate/deactivate global kill switch
    p0-gatewayBenign ALLOW + injection BLOCK
    p0-policiesCreate new policy
    p0-violationsTriage open violation
    ai/askAsk page (requires real GEMINI_API_KEY)

    Out of scope (root CI)

  • WrapSec subtree pytest (integrations/wrapsec/tests/) — separate workflow under integrations/wrapsec/.github/