Skip to content

Testing

Kangentic uses a three-tier testing strategy. Each tier targets a different layer of the application, and each has its own tradeoffs between speed, coverage, and realism.

The four test tiers and the captures project, from pure logic to a real Electron window.

Terminal window
npm run test:unit
  • Runner: Vitest
  • Speed: Sub-second
  • What to test: Pure logic - parsers, filters, state machines, utility functions
  • No build needed, no browser, no Electron

Unit tests live in tests/unit/. They’re fast and focused - test a function’s input/output without any framework overhead.

There is also an opt-in integration tier in tests/integration/. Those tests hit real CLIs, the file system, or the network, so while vitest.config.ts includes them, npm run test:unit pins the tests/unit path and skips them. Run them on demand with npx vitest run tests/integration/.

Terminal window
npx playwright test --project=ui
  • Runner: Playwright with headless Chromium
  • Speed: Fast - hundreds of tests run headless in parallel
  • What to test: React components, forms, dialogs, drag-and-drop, board interactions
  • No build needed locally - a local run loads the app from the Vite dev server, which Playwright starts, so an edit shows on the next run. Since v0.60.0 CI builds the renderer once per shard as a static development bundle and serves that instead, because the dev server answered one request per source module, 759 of them into a browser context with no cache, and that boot was most of what a UI test cost. npm run test:ui:bundle -- tests/ui/<spec> runs a spec the CI way, for one that fails on CI and passes locally
  • Reaching the app from a spec - through window.__zustandStores and window.__kangenticTestModules, never an import('/src/renderer/...') in the page, because a bundle serves no source path. A spec that needs the dev server itself loads it from DEV_SERVER_URL in tests/ui/dev-server.ts after one warmDevServer() call, and a unit test fails a spec that does neither

UI tests live in tests/ui/. They use a full in-memory mock of window.electronAPI (injected via addInitScript()) that supports complete CRUD for projects, tasks, swimlanes, automations, sessions, config, and attachments.

Use window.__mockPreConfigure(fn) to set up mock state before React mounts.

Terminal window
npm run build
npx playwright test --project=electron
  • Runner: Playwright with _electron.launch()
  • Speed: Slower - opens real windows (no headless mode on Windows)
  • What to test: PTY sessions, terminal rendering, session lifecycle, shell detection, config persistence
  • Build required before running

E2E tests live in tests/e2e/. These exercise the full Electron application with real IPC, real file I/O, and real terminal sessions.

Terminal window
npm run build:demo
npm run test:demo

Playwright’s config also declares a demo project (tests/demo/), the fourth alongside ui, electron, and captures, since v0.42.0. It is a small smoke tier for the static web build of the renderer that the website embeds: npm run build:demo writes dist/demo/, and the spec serves that folder itself on an ephemeral port and loads it in headless Chromium at the site frame’s 1600x1000 viewport, one worker locally and three on CI, where the project runs fully parallel. It has no entry in the shared webServer block on purpose, so a missing demo build surfaces as one named error rather than breaking the UI tier. CI runs it as its own always-on job, Web demo (build + smoke).

Terminal window
npm run capture

Playwright also declares a captures project (tests/captures/, *.capture.ts files). It is not a test tier: it produces screenshots and screen recordings of staged app states for marketing and documentation. npm run capture builds the web demo first; the scene captures render against that static build, while the walkthrough and orchestration captures drive the same mocked renderer as the UI tier through the Vite dev server. Run it on demand.

What you’re testing Tier
Logic, parser, store, state machine, repo convention Unit
Layout, focus, keyboard, drag, a visible state UI
Real PTY, file watcher, restart, kill, worktree E2E
The web build boots and stays embeddable Demo smoke
Terminal window
npm run test:unit # Unit tests (Vitest)
npx playwright test --project=ui --project=electron # UI + E2E tests (Playwright)

Every pull request runs the full suite on GitHub Actions. Lint, type check, and a production build run as three independently reported steps of one Lint, Typecheck, Build job, so a failing lint step never hides a type error. The four test tiers run as sharded matrices on Linux (Node 24 since v0.44.0), each behind a thin gate job that is its status check. Branch protection requires the first three:

Tier Where it runs in CI Shards
Unit (Vitest) Linux 3
UI (Playwright, headless Chromium) Linux, on a static development bundle 11
E2E (Electron) Linux under xvfb 3
Web demo (build + smoke) Linux 2

Since v0.60.0 the tiers are sized to finish together, because a pull request waits on every check, required or not. Loading the UI tier from a bundle cut its test time about in half, from 12,355 seconds a run to 6,841, so no tier is far ahead any more: measured on 2026-11-17, a UI shard’s job took 225 to 390 seconds, a web demo shard 250 to 340, and a unit shard with its gate 200 to 275. E2E gave two of its five slots to the unit tier and the web demo. The UI shards are no longer Playwright’s even-count windows: scripts/ui-shard-plan.mjs hands each shard whole spec files by their measured time, from tests/ui/shard-timings.json, and the Lint, Typecheck, Build job fails a plan that leaves a spec out. A new spec is weighed by its test count until the timings are refreshed from a green run.

A push to main usually runs none of it. main requires a pull request to be up to date and pull requests land by rebase, so a merge puts on main the tree its own head already passed on. The push’s first job, Tree already tested, checks that and passes in seconds, and every other job skips. A direct push runs everything, and so does any doubt about the tree.

The E2E tier runs only on Linux in CI. The suite is platform-neutral, so Linux covers the macOS and Linux users while the team dogfoods the Windows build locally. On CI each E2E shard runs at workers=8; any local (non-CI) run, on every OS, pins the E2E project to workers=1 - Windows cannot run concurrent electron.launch(), and a local run on any platform should not spawn a swarm of app windows - so a local E2E run is serial and opens real windows.

A spawn’s typed launch has its own round trip, tests/unit/typed-launch-round-trip.test.ts, which types each shell’s launcher form into a real shell with a controlled startup delay and asserts what a stub agent received, never the scrollback. shell-quoting-posix.yml runs it under bash, zsh, fish, and nushell. macos-spawn-helper.yml runs it under real zsh, the one place the 1024-byte tty limit applies, and once more under a pinned powerlevel10k with instant prompt, which draws a prompt before the startup files finish. Since v0.55.0 macos-spawn-helper.yml also runs a failed launch through real zsh, in launch-failure-real-shell.test.ts. Both workflows are path-filtered.

Kangentic is free and open source. A star helps other people find it.

Star on GitHub