feat: migrate test runner from Bun to Vitest

- Replace bun:test with Vitest across all 22 test files
- Create @sofa/test package with shared setup and DB test helpers
  - setup.ts: vi.mock for @sofa/db/client, Bun.randomUUIDv7 polyfill
  - db.ts: in-memory SQLite via better-sqlite3, seed helpers
- Add per-project vitest configs (packages/core, apps/web)
- Add root vitest.config.ts with projects and v8 coverage
- Set up @vitest/browser + Playwright for web component tests
- Move validateBackupDatabase from core/backup.ts to @sofa/db/client
- Derive required backup tables from schema instead of hard-coded list
- Update CI workflow with Playwright install and Codecov upload
- Update CLAUDE.md documentation for Vitest

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-22 12:03:06 -04:00
co-authored by Claude Opus 4.6
parent 3f05e08fea
commit 5f3e14b415
45 changed files with 589 additions and 364 deletions
+9 -5
View File
@@ -10,7 +10,8 @@
"lint": "oxlint",
"format": "oxfmt --config ../../.oxfmtrc.json",
"format:check": "oxfmt --check --config ../../.oxfmtrc.json",
"check-types": "tsc --noEmit"
"check-types": "tsc --noEmit",
"test": "vitest run"
},
"dependencies": {
"@base-ui/react": "1.3.0",
@@ -28,7 +29,7 @@
"@tabler/icons-react": "3.40.0",
"@tanstack/react-hotkeys": "0.4.2",
"@tanstack/react-query": "catalog:",
"@tanstack/react-router": "1.168.1",
"@tanstack/react-router": "1.168.2",
"better-auth": "catalog:",
"class-variance-authority": "0.7.1",
"clsx": "2.1.1",
@@ -51,16 +52,19 @@
"@tanstack/devtools-vite": "0.6.0",
"@tanstack/react-devtools": "0.10.0",
"@tanstack/react-query-devtools": "5.94.5",
"@tanstack/react-router-devtools": "1.166.10",
"@tanstack/router-plugin": "1.167.2",
"@tanstack/react-router-devtools": "1.166.11",
"@tanstack/router-plugin": "1.167.3",
"@types/bun": "catalog:",
"@types/node": "catalog:",
"@types/react": "catalog:",
"@types/react-dom": "19.2.3",
"@vitejs/plugin-react": "6.0.1",
"@vitest/browser": "catalog:",
"@vitest/browser-playwright": "catalog:",
"babel-plugin-react-compiler": "1.0.0",
"tailwindcss": "catalog:",
"typescript": "catalog:",
"vite": "8.0.1"
"vite": "8.0.1",
"vitest": "catalog:"
}
}
+1 -1
View File
@@ -1,4 +1,4 @@
import { describe, expect, test } from "bun:test";
import { describe, expect, test } from "vitest";
import { getThemeCssProperties, hexToRelativeLuminance } from "./theme";
+13
View File
@@ -0,0 +1,13 @@
import { playwright } from "@vitest/browser-playwright";
import { defineProject } from "vitest/config";
export default defineProject({
test: {
include: ["src/**/*.test.{ts,tsx}"],
browser: {
enabled: true,
provider: playwright(),
instances: [{ browser: "chromium", headless: true }],
},
},
});