Skip to content

Add tests for the WGC recorder process (src/wgcRecorder.ts, 0% coverage) #296

Closed

Description

@TMHSDigital

Summary

src/wgcRecorder.ts does frame slicing, wall-clock pacing, backpressure frame drops and has five exit paths, but has no tests. Only pure helpers in utils/wgc.ts are tested.

Where

  • src/wgcRecorder.ts:81-90 (drain)
  • src/wgcRecorder.ts:107-134 (pacing, frame drop)
  • src/wgcRecorder.ts:143-166 (finish, window closed)
  • src/wgcRecorder.ts:168-174 (first-frame timeout)
  • src/wgcRecorder.ts:176-187 (stop file, stdin)

Details

Real WGC recording is only exercised by the local-only localCapture.test.ts:342.

Impact

A regression would truncate or corrupt window recordings, or leave orphaned ffmpeg/PowerShell children (#208), with nothing to catch it.

Suggested fix

Point cfg.ffmpeg at a fake Node script that prints a WxH size line on stderr and raw yuv420 frames on stdout, spawn dist/wgcRecorder.js, and assert:

Acceptance criteria

  • Checklist cases covered
  • Pairs with the WGC frame-assembly performance fix (chunk boundaries)

Getting started

  • Relevant files: src/wgcRecorder.ts
  • How to run tests: npm run build && npm test (also npm run typecheck and npm run lint)
  • Related docs: CONTRIBUTING.md, AGENTS.md

Filed by repo-audit/full-audit at f2fda28. Severity: medium. Effort: M. audit-key: testing|src/wgcRecorder.ts|drain

Activity

  1. added
    help wanted
    testing
    on Nov 9, 2026
  2. TMHSDigital commented on Nov 10, 2026

    @TMHSDigital
    OwnerAuthor

    Fixed in 59e4eff. src/__tests__/integration/wgcRecorder.test.ts runs the built dist/wgcRecorder.js with an --import preload that replaces child_process.spawn with fake grab, encoder and nudge scripts written in Node. Because nothing real is captured, it runs on every CI leg.

    All items on the checklist are covered:

    • "q" on stdin, closing stdin, and the stop file each end the recording with exit 0, a start banner, and roughly fps × seconds frames. The stop file is removed afterwards.
    • A window that closes after sending frames exits with WGC_WINDOW_CLOSED_EXIT.
    • A grab that fails before the first frame exits 1 with "capture failed".
    • If no frame arrives in time, it exits 1. The timeout is now injectable through WgcRecorderConfig.firstFrameTimeoutMs, which defaults to 10 s.
    • Frame bytes that arrive before the size line still split into whole frames. The fake encoder checks that every frame is uniform, so a frame split at the wrong byte would fail the test.
    • A stalled encoder causes frames to be dropped rather than queued.
    • maxDurationSec ends the recording.
    • On every exit path, no child process is left running.

    These run in a child process, so they don't add line coverage for wgcRecorder.ts.

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

    help wantedpriority: mediumtesting

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions