This document describes how automated testing is set up in bar-lobby, and how to run tests locally and in CI.
- Unit / integration tests: Vitest
- End-to-end (E2E) tests: Playwright launching the Electron app
npm ci
npm run test
npm run test:e2eUse unit tests for:
- Pure functions and business logic
- Modules with well-defined boundaries (mock IO/network as needed)
- Renderer logic that can be exercised without a full Electron runtime
npm run testRun a subset:
npx vitest run tests/some.test.tsE2E tests launch the Electron app and interact with the real browser window(s) via Playwright. This exercises:
- Electron main process startup
- Window creation / BrowserWindow lifecycle
- Renderer load + DOM availability
E2E is a good place for:
- “App boots” / “critical views render” checks
- High-value workflows that cross main/renderer boundaries
- Regression coverage for production-only issues (packaging, preload wiring, navigation, etc.)
npm run test:e2eDebug mode:
PWDEBUG=1 npm run test:e2eIf Electron fails immediately, check:
- Are you hitting Linux sandbox errors? In CI, add
--no-sandboxfor Electron.
This repo is ESM ("type": "module"), so __dirname and __filename are not defined in tests.
To resolve paths relative to the current test file, use import.meta.url:
const __dirname = path.dirname(fileURLToPath(import.meta.url));Run E2E with Xvfb:
xvfb-run -a npm run test:e2e