Skip to content

proposal(7): Vitest + MSW + Playwright + CI matrix#19

Open
christian-byrne wants to merge 1 commit intoComfy-Org:mainfrom
christian-byrne:proposal/testing-ci
Open

proposal(7): Vitest + MSW + Playwright + CI matrix#19
christian-byrne wants to merge 1 commit intoComfy-Org:mainfrom
christian-byrne:proposal/testing-ci

Conversation

@christian-byrne
Copy link

Proposal #7: Testing Infrastructure

What

Add a complete testing strategy from zero: Vitest for unit tests, Playwright config for future E2E, and a GitHub Actions CI matrix that runs tests on all 3 platforms.

PoC Deliverables

  • 41 passing unit tests across 5 files in ~150ms:
    • lib/util.jsparseUrl, formatTime, parseArgs (16 tests)
    • lib/i18n.jst(), param substitution, locale fallback (7 tests)
    • installations.js — full CRUD: add, remove, update, get, reorder (10 tests)
    • sources/git.jsbuildInstallation, source metadata (4 tests)
    • sources/standalone.jsbuildInstallation, getDefaults (4 tests)
  • Vitest config — Node environment targeting main-process CJS code
  • Playwright config — placeholder for Electron E2E tests
  • CI workflow.github/workflows/test.yml with ubuntu/windows/macos matrix
  • Proposal document.github/proposals/proposal-testing-ci.md with full testability matrix

Key Technical Finding

Vitest 4.x does not intercept CJS require() calls (vitest-dev/vitest#3134). To mock electron for modules like installations.js → lib/paths.js → require('electron'), we override Module._load via vi.hoisted(). This is the standard community workaround and will become unnecessary after ESM migration.

What's NOT Included (future work)

  • MSW integration tests (deferred to keep scope small)
  • @playwright/test dependency (config-only placeholder)
  • E2E test fixtures
  • Coverage thresholds

Run it

npm install
npm test  # 41 tests, ~150ms

See .github/proposals/proposal-testing-ci.md for the full proposal with tradeoffs and roadmap.

Add testing infrastructure proposal with working PoC:

- Vitest config (Node environment for main-process code)
- 41 passing unit tests across 5 files:
  - lib/util.js: parseUrl, formatTime, parseArgs (16 tests)
  - lib/i18n.js: t(), param substitution, fallback (7 tests)
  - installations.js: full CRUD + reorder (10 tests)
  - sources/git.js: buildInstallation, metadata (4 tests)
  - sources/standalone.js: buildInstallation, getDefaults (4 tests)
- Module._load shim for mocking electron in CJS code
- Playwright config placeholder for future E2E tests
- GitHub Actions test.yml with 3-platform matrix
- Proposal document with testability matrix and roadmap

Key technical finding: Vitest does not intercept CJS require()
calls, so electron must be shimmed via Module._load override.
This workaround is well-documented and will be unnecessary
after ESM migration (Proposal Comfy-Org#1).

Amp-Thread-ID: https://ampcode.com/threads/T-019c7926-be08-704f-b583-1c5167315271
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