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
+3 -3
View File
@@ -1,4 +1,4 @@
import { beforeEach, describe, expect, spyOn, test } from "bun:test";
import { beforeEach, describe, expect, test, vi } from "vitest";
import {
importJobs,
@@ -15,7 +15,7 @@ import {
insertTvShow,
insertUser,
testDb,
} from "@sofa/db/test-utils";
} from "@sofa/test/db";
import * as tmdbClient from "@sofa/tmdb/client";
import type { NormalizedImport } from "../src/imports/parsers";
@@ -435,7 +435,7 @@ describe("processImportJob — failed resolution", () => {
};
// Mock TMDB search to return empty results (no network call)
const searchSpy = spyOn(tmdbClient, "searchMovies").mockResolvedValue({
const searchSpy = vi.spyOn(tmdbClient, "searchMovies").mockResolvedValue({
results: [],
} as never);