hermes-agent/apps/desktop/vitest.config.ts
teknium1 989798cd5e fix(desktop): test runs stop leaking temp dirs into TMPDIR
Hermes points TMPDIR at ~/.hermes/cache/scratch, so every Desktop test
run's leftovers pile up there until the 24h idle pruner catches them:
one day on a dev host left 688 playwright-tracing-*, 152
playwright-artifacts-*, 75 hermes-e2e-mock-* sandboxes and ~600 small
vitest mkdtemp dirs.

- Playwright (main + core configs): e2e/run-tmp.ts gives the run one
  temp root that workers, Electron and the backend inherit via TMPDIR,
  and removes it when the runner exits. Covers the stack-trace dirs the
  Electron tracing patch orphans (2 per launch, even on green runs),
  sandboxes a failed/timed-out setup never cleans, and Playwright's own
  artifact dirs. A SIGKILLed run now leaves one pw-* dir for the pruner.
  The update suite keeps os.tmpdir(): its seeded install is reused
  across runs and bakes its path into AF_UNIX sockets.
- vitest (apps/desktop): globalSetup does the same for the run; one
  `--project electron` run left 54 dirs from tests that never remove
  what they mkdtemp.
2026-09-27 23:10:22 -07:00

40 lines
1.4 KiB
TypeScript

import type { TestProjectConfiguration } from 'vitest/config'
import { defineConfig } from 'vitest/config'
const reactUi: TestProjectConfiguration = {
extends: './vite.config.ts',
test: {
name: 'ui',
environment: 'jsdom',
// Keep padding regressions observable instead of mocking the stylesheet away.
css: { include: [/status-stack\.css$/] },
setupFiles: ['./vitest.setup.ts'],
include: ['src/**/*.test.{ts,tsx}'],
globals: true,
// The first test in each file pays jsdom env init + full module transform,
// which can exceed vitest's 5000ms default under CI/load. 15s gives the
// cold start headroom without masking genuinely hung tests. Hooks pay the
// same cold cost when a beforeEach does `vi.resetModules()` + `await
// import(...)` (65 files); one timed out at 10s on CI (#120318).
testTimeout: 15_000,
hookTimeout: 30_000
}
}
const electronNative: TestProjectConfiguration = {
test: {
name: 'electron',
environment: 'node',
// `e2e/**/*.unit.test.ts` is the e2e HELPERS, not the specs: plain node
// modules that should be provable without booting Electron. Playwright
// ignores the same pattern so they run in exactly one runner.
include: ['electron/**/*.test.ts', 'scripts/**.test.{ts,mjs}', 'e2e/**/*.unit.test.ts']
}
}
export default defineConfig({
test: {
globalSetup: ['./vitest.run-tmp.ts'],
projects: [reactUi, electronNative]
}
})