Skip to content

Migrate to vitest: setup + leaf modules #281

@thymikee

Description

@thymikee

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

Add vitest alongside node:test. Migrate leaf modules that have no downstream consumers of their DI params.

Setup

  • Add vitest as dev dependency
  • Configure vitest.config.ts (coexist with node:test during migration)
  • Update CI to run both runners

Files to migrate (15 DI params removed)

src/daemon/recording-telemetry.ts (1 param)

  • Remove writeTelemetry?: typeof writeRecordingTelemetry
  • Rewrite test with vi.mock

src/daemon/handlers/find.ts (1 param)

  • Remove dispatch?: typeof dispatchCommand
  • Rewrite __tests__/find.test.ts with vi.mock('../../core/dispatch.ts')

src/daemon/handlers/install-source.ts (7 params)

  • Remove deps object: resolveInstallDevice?, getRequestSignal?, prepareIosInstallArtifact?, installIosInstallablePath?, prepareAndroidInstallArtifact?, installAndroidInstallablePathAndResolvePackageName?, inferAndroidAppName?
  • Rewrite __tests__/install-source.test.ts with vi.mock for each platform import

src/daemon/handlers/session-runtime-command.ts (1 param)

  • Remove clearRuntimeHints?: typeof clearRuntimeHintsFromApp
  • Rewrite relevant test with vi.mock('../runtime-hints.ts')

src/daemon/android-system-dialog.ts (4 params)

  • Remove snapshotAndroidUi?, reopenAndroidApp?, readAndroidAppState?, execCommand?
  • Rewrite __tests__/request-router-android-modal.test.ts with vi.mock

src/daemon/handlers/interaction-snapshot.ts (1 param)

  • Remove dispatch: typeof dispatchCommand = dispatchCommand default-value DI
  • Mock dispatch in calling test

Validation

  • pnpm typecheck
  • pnpm test:unit (node:test suite still passes)
  • vitest suite passes for migrated files
  • No optional typeof params remain in touched files

CI lint guard

Add to CI: rg '\?\s*:\s*typeof\s+' <touched files> must return zero matches.

Part of migration: #1#2#3#4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions