Skip to content

perf: build-mds.test.ts 18 spawnSync calls per test run (hoist to module scope) #293

Description

@dean0x

Problem

tests/build-mds.test.ts runs 18 spawnSync full MDS build invocations in separate describe blocks, one per command file being tested. This causes suite-runtime sensitivity: total test time swings from 15s (quiet machine) to 10min+ (load).

Current structure:

  • 18 describe() blocks
  • Each describe() invokes full npm run build:mds via spawnSync
  • Sequential execution × 18 = 18× build time in test suite alone

Context

  • Pre-existing pattern identified as suite-runtime sensitivity blocker
  • Related to suite timing variability (noted in memory context)
  • Opportunities to consolidate MDS build setup

Solution

  1. Hoist MDS build to module scope — run single npm run build:mds before all tests
  2. Cache build output — all 18 describe blocks read from cache, zero rebuild
  3. Verify incremental — add a smoke test to detect stale cache (rebuild on source change)
  4. Measure — compare suite time: 18× individual builds vs 1× shared + 18× cache reads

Acceptance Criteria

  • Single module-scope MDS build before test suite
  • Cache invalidation on src/assets/commands/ changes detected
  • All 18 tests pass using cached build output
  • Suite runtime reduced to <20s on typical machine
  • No timing flakiness under load (test passes consistently)
  • Change documented as performance optimization in code comments

Related

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    qualityCode quality improvementstech-debtTechnical debt items to address

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions