Skip to content

CS-10346: vitest migration scaffolding + first leaf test#4841

Draft
lukemelia wants to merge 2 commits into
mainfrom
cs-10346-migrate-test-harness-to-vitest
Draft

CS-10346: vitest migration scaffolding + first leaf test#4841
lukemelia wants to merge 2 commits into
mainfrom
cs-10346-migrate-test-harness-to-vitest

Conversation

@lukemelia
Copy link
Copy Markdown
Contributor

Summary

Foundational PoC for migrating the realm-server test harness from QUnit to Vitest (CS-10346). Recovers Ian's AST-based codemod from his stale March branch, rewires it against current tests/, and graduates one leaf test as proof the loop works end-to-end.

This is stage 1 scaffolding, not the actual migration. Strictly additive: the QUnit suite is untouched and remains the load-bearing test runner.

What's here

  • scripts/codemods/qunit-to-vitest.ts — Ian's AST codemod (995 lines, TypeScript compiler API). Run via pnpm codemod:qunit-to-vitest. On the current tests/ tree it transforms 111 test files + copies 77 support files; only one file (card-reference-resolver-test.ts) flags unsupported asserts (11x assert.throws(..., /regex/, ...) to translate by hand).
  • tests-vitest/ — parallel codemod output tree. .gitignore allowlists files only as they graduate to vitest, so the auto-generated tree stays out of git.
  • vitest.config.ts — minimal config, singleThread: true (parallelism deferred to a separate ticket).
  • tests-vitest/async-semaphore.test.ts — first graduate. pnpm test:vitest → 18/18 passing in 3ms.

Migration plan (this PR = stage 1.a)

  1. Stage 1 — leaf tests + CI hookup. Graduate ~10 pure-utility tests (no servers, no DB, no helpers/), wire CI to run test:vitest. (Continues on this branch — TODO before un-draft.)
  2. Stage 2 — port helpers/ + @cardstack/realm-test-harness to be harness-agnostic. This is where Ian's "some still failing" tests live.
  3. Stage 3 — graduate server tests in waves grouped by helper-affinity; delete each QUnit twin as vitest version goes green.
  4. Stage 4 — kill QUnit (delete tests/index.ts registry, signal handlers, undici teardown, qunit dep). Move tests-vitest/tests/.
  5. Separate ticket — parallelism (per-worker DBs + dynamic port allocation).

Graduation workflow

Each file that goes vitest:

  1. Re-run pnpm codemod:qunit-to-vitest.
  2. Add filename to tests-vitest/.gitignore allowlist.
  3. Add filename to vitest.config.ts include[].
  4. Run pnpm test:vitest and fix anything the codemod didn't translate.

Test plan

  • pnpm -F @cardstack/realm-server test:vitest passes locally (18/18, ~100ms).
  • QUnit suite still passes (this PR adds files only).
  • CI wiring lands in a follow-up commit on this branch before un-drafting.

🤖 Generated with Claude Code

lukemelia and others added 2 commits May 14, 2026 17:02
Recovers Ian's QUnit→Vitest codemod (995 lines, AST-based via the
TypeScript compiler API) from the 9-months-stale branch and rewires
it against current realm-server tests:

- Codemod writes `tests-vitest/` as a parallel tree of `.test.ts`
  files; the QUnit suite under `tests/` is untouched. Running the
  codemod transforms 111 tests + copies 77 support files; one file
  (card-reference-resolver-test.ts) flags 11 `assert.throws(...,
  /regex/, ...)` calls for manual follow-up.
- `tests-vitest/.gitignore` allowlists files only as they graduate to
  vitest, so the auto-generated tree stays out of git.
- `vitest.config.ts` runs singleThread to match QUnit's serial model
  while parallelism is deferred to a later phase.
- `async-semaphore.test.ts` is the first graduate: 18/18 passing in
  3ms via `pnpm run test:vitest`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Adds a `realm-server-vitest-test` job gated on the same path filter
  as the main realm-server-test matrix. Currently runs the single
  async-semaphore test (18 assertions, ~100ms) — the harness is the
  point, not the coverage. As more files graduate, the job picks them
  up via vitest.config.ts include[].
- Documents in vitest.config.ts why other leaf candidates can't
  graduate yet: vite eager-walks @cardstack/runtime-common's TS
  source graph and can't resolve transitive pnpm-hoisted deps
  (acorn, magic-string) that aren't direct deps of realm-server.
  server.deps.external / ssr.external don't intercept the transform
  path. Stage 1.b will resolve this; until then only tests that
  don't import runtime-common can move.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 14, 2026

Host Test Results

    1 files      1 suites   1h 37m 56s ⏱️
2 658 tests 2 643 ✅ 15 💤 0 ❌
2 677 runs  2 662 ✅ 15 💤 0 ❌

Results for commit c193b2d.

Realm Server Test Results

    1 files  ±    0      1 suites  +1   9m 29s ⏱️ + 9m 29s
1 377 tests +1 377  1 377 ✅ +1 377  0 💤 ±0  0 ❌ ±0 
1 458 runs  +1 458  1 458 ✅ +1 458  0 💤 ±0  0 ❌ ±0 

Results for commit c193b2d. ± Comparison against earlier commit 61d3eb3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant