Skip to content

Migrate to vitest: session.ts orchestrator + drop node:test #284

Description

@thymikee

Step 4 of 4: Drop test-only DI with vitest module mocking

Final step. By now all sub-handlers own their imports directly — the orchestrator params have no consumers left.

Files to migrate (~24 DI params removed)

src/daemon/handlers/session.ts (18 optional params)

  • Remove all optional DI params from handleSessionCommands:
    dispatch?, ensureReady?, resolveTargetDevice?, installOps?, reinstallOps?, stopIosRunner?, dismissMacOsAlert?, appLogOps?, ensureAndroidEmulatorBoot?, resolveAndroidPackageForOpen?, applyRuntimeHints?, clearRuntimeHints?, settleSimulator?, shutdownSimulator?, shutdownAndroidEmulator?, listAndroidDevices?, listAppleDevices?, listAppleApps?
  • Remove ~6 required threaded params from internal functions (runSessionOrSelectorDispatch, handleClipboardCommand, maybeResolvePushPayloadPath wiring, etc.)
  • All *Override local aliases (dispatchOverride, ensureReadyOverride, etc.) collapse to direct imports

Tests to rewrite:

  • handlers/__tests__/session.test.ts (main orchestrator tests)
  • Any remaining node:test files

Drop node:test runner

  • Remove node:test from CI config
  • Remove any dual-runner configuration from vitest.config.ts
  • Convert any stragglers still using node:test + node:assert

Add permanent CI lint guard

# Fail if test-only DI seams reappear in production code
rg '\?\s*:\s*typeof\s+' src/ --glob '!**/__tests__/**' --glob '!*.test.ts'

Validation

  • pnpm typecheck
  • pnpm test:unit (vitest only now)
  • pnpm test:smoke
  • Lint guard passes with zero matches

Expected result

  • ~99 typeof DI params removed across ~20 production files
  • Test files use vi.mock instead of constructing DI param bags
  • handleSessionCommands signature drops from ~30 params to ~5 (req, sessionName, sessionStore, logPath, invoke)

Depends on #283. Part of migration: #1#2#3→**#4**

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions