Skip to content

how to contribute testing

Claude edited this page Sep 23, 2026 · 2 revisions

Testing

MyPrompt uses two runners. Vitest covers unit and renderer logic. Playwright drives the built Electron shell end to end.

Vitest

Configuration is vitest.config.ts: environment: 'jsdom', globals: true, and include: ['__tests__/**/*.test.ts']. The @vitejs/plugin-react and an @ alias that resolves to the capsule root let tests import product code the same way desktop/main.ts does.

Suites live under __tests__/:

Directory Files
optimizer/ clarification.test.ts, coding-brief-format.test.ts, coding-brief-generation.test.ts, coding-brief-refinement.test.ts, coding-brief-v3.test.ts, optimizer-quality.test.ts, provider-stream.test.ts, super-prompt-format.test.ts
desktop/ console-theme.test.ts, console-transcript.test.ts, optimizer-failure.test.ts, system-hud.test.ts, window-drag.test.ts
llm/ provider-readiness.test.ts
compiler/ compiler-profiles.test.ts

The optimizer/ suite exercises the Super Prompt format, the Coding Brief format/generation/refinement/v3 validator path, clarification rounds, optimizer quality, and streaming. The desktop/ suite covers the console theme and transcript, the failure taxonomy, the system HUD stats, and window drag behavior. The llm/ suite checks provider readiness resolution. The compiler/ suite checks the Claude, Codex, Gemini, and Grok compiler profiles.

Acceptance pretest

pnpm run test first runs pretest, which executes scripts/optimizer-acceptance.ts --dry-run through tsx. This validates the acceptance harness cases without making live provider calls. The full harness runs with pnpm run optimizer:acceptance or pnpm run desktop:benchmark --json.

Playwright end to end

Configuration is playwright.config.ts: testDir: './e2e', fullyParallel: false, workers: 1, reporter: 'line', timeout: 30_000. The single spec is e2e/transform.e2e.spec.ts, with screenshot baselines in e2e/transform.e2e.spec.ts-snapshots/. It launches the built dist-electron/desktop/bootstrap.js with a temporary userData directory and blanked provider keys so the boot state is identical on every machine.

Commands:

  • pnpm run test:e2e builds the desktop bundle, then runs playwright test.
  • pnpm run test:desktop runs only vitest run __tests__/desktop.
  • pnpm run test:watch and pnpm run test:coverage wrap Vitest directly.

Adding a test

Create a file under the matching __tests__/<area>/ directory named <subject>.test.ts. Import describe, it, expect, and vi from vitest, and import product code through the @/ alias (for example @/lib/optimizer/engine). When a test must not reach a real provider, mock @/lib/llm/provider-registry with vi.mock, as __tests__/optimizer/optimizer-quality.test.ts does. The include glob picks the new file up automatically; run it with pnpm exec vitest run __tests__/<area>/<subject>.test.ts.

See Debugging for reading failures and Tooling for the runner versions.

Clone this wiki locally