Test hygiene: coverage floors, leaked temp dirs, dist-dependent tests

Ouverte
#503 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

Évaluation

Difficulté
4/5
Temps estimé
3-5 jours
Accessibilité débutants
38/100
Type d'issue
Refactorisation
Clarté
Clairement spécifiée
Activité
Active
Stack technique
github-actions, typescript
Domaine
ci-cd, devtools, testing

Piste de recherche

Start with the listed test files, vitest.config.ts, .github/workflows/publish.yml, and ci.yml; read CONTRIBUTING.md and AGENTS.md, then run npm run build && npm test. The issue lists six separate test and CI problems, with locations, triggers, and proposed fixes. Done means each item is fixed or closed with a reason and npm test passes.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

effort: medium help wanted priority: low testing

Summary

Lower-priority test and CI items. The suite passed during the audit (1,755 passed, 30 skipped, 92.5% lines).

Related: #302

Items

  • Coverage floors trail measured coverage by up to 30 points and skip most high-risk files
    Where: vitest.config.ts:16, vitest.config.ts:20, vitest.config.ts:27, vitest.config.ts:28, vitest.config.ts:30, vitest.config.ts:31

    Floors against this run (which lacks the capture smoke, so CI is equal or higher): src/utils/** lines 90 vs 96.60; src/tools/** 77 vs 85.34; events.ts 66 vs 96.65; lifecycle.ts 77 vs 93.84; sessions.ts 88 vs 93.19; recorder.ts lines 88 vs 96.80, branches 60 vs 69.23. The comment at vitest.config.ts:22-24 quotes Nov 2026 figures (events 70.0, lifecycle 81.1) that the lifecycle tests have since passed. Only recorder.ts has a branch floor; there is none for functions. No floor at all covers top-level src/*.ts (cli.ts 89.16, setup.ts 77.64, serverLifecycle.ts 67.24 lines / 18.75 functions) or the confinement and delete files (paths.ts, roots.ts, argPaths.ts, validate.ts, expr.ts, editSpec.ts, retention.ts, fileLock.ts, src/tools/deleteRecording.ts), which are at 92-100% today only by habit. src/tools/** branches are 62.96% with no floor.

    Trigger: Compare vitest.config.ts thresholds with coverage/coverage-summary.json after npm run test:coverage.

    Fix: Read the numbers from a green CI run's coverage summary (Windows Node 22 leg), then set each floor about 3 points under: src/utils/** lines ~93 and branches ~84; events.ts ~93; lifecycle.ts ~90; sessions.ts ~90; recorder.ts ~93 / branches ~65; src/tools/** ~82 and branches ~58. Add per-file floors for paths.ts, roots.ts, argPaths.ts, validate.ts, expr.ts, editSpec.ts (lines 95), retention.ts, fileLock.ts, pipelineRun.ts, src/tools/deleteRecording.ts, src/cli.ts, src/setup.ts. Update the stale comment.

  • Five test files leave a temp directory behind on every run
    Where: src/__tests__/editTool.test.ts:11, src/__tests__/argPathsCoverage.test.ts:14, src/__tests__/schemaParity.test.ts:13, src/__tests__/color.test.ts:39, src/__tests__/deleteRecording.test.ts:21, src/__tests__/deleteRecording.test.ts:64

    editTool.test.ts, argPathsCoverage.test.ts, schemaParity.test.ts and color.test.ts call mkdtempSync(join(tmpdir(), "sc-...-")) at module or describe scope and contain no rmSync or afterAll. deleteRecording.test.ts removes home in the first describe's afterAll (line 64), but the second describe (from about line 180) builds another server on the same SCREENCAST_HOME, which recreates edits/, recordings/ and sessions.json; its afterAll (line 195) only closes the client. After this audit's run the OS temp folder held new sc-edittool-*, sc-argcov-*, sc-parity-*, sc-lut-* and sc-delete-* directories; the machine has 615 sc-* entries in total (168 parity, 147 edittool, 120 argcov, 110 delete, 55 lut).

    Trigger: Count sc-* entries in %TEMP%, run npm test, count again: five more.

    Fix: Add afterAll(() => rmSync(dir, { recursive: true, force: true })) to the four files; in deleteRecording.test.ts move the rmSync(home, ...) to a file-level afterAll that runs after both describes.

  • Tests of the built entry points skip when dist/ is missing and trust a stale build when it exists
    Where: src/__tests__/integration/entryStdio.test.ts:19, src/__tests__/integration/entryStdio.test.ts:63, src/__tests__/entryCli.test.ts:7, src/__tests__/entryCli.test.ts:9, src/__tests__/integration/wgcRecorder.test.ts:18, src/__tests__/integration/wgcRecorder.test.ts:142, package.json:29

    Three suites spawn dist/index.js or dist/wgcRecorder.js and are wrapped in describe.skipIf(!existsSync(...)). "test": "vitest run" has no build step, and REQUIRE_FFMPEG=1 does not make a missing dist/ a failure. These are the only tests of src/index.ts and src/wgcRecorder.ts (both 0% in the coverage report, because child processes are not measured; the config comment tracks that under #295 and #296). CI runs npm run build before npm test on every leg, so CI is sound today.

    Trigger: Delete dist/, run npm test: three suites report skipped and the run is green. Or change the 'q' handling in src/wgcRecorder.ts and run npm test without building: wgcRecorder.test.ts still passes.

    Fix: In those three files, fail instead of skip when process.env.CI or REQUIRE_FFMPEG is set and the bundle is missing (the pattern ffmpeg.test.ts:77 uses for ffmpeg). For staleness, compare the bundle's mtime with the newest file under src/ (excluding __tests__) and fail with "run npm run build", or add a vitest globalSetup that runs the build.

  • publish.yml's own test step runs on Linux without ffmpeg, so 16 integration suites skip
    Where: .github/workflows/publish.yml:15, .github/workflows/publish.yml:28, src/__tests__/integration/ffmpeg.test.ts:77

    The build-test job that builds and packs the tarball that gets published runs npm test on ubuntu-latest with no ffmpeg install step and without REQUIRE_FFMPEG. Every describe.skipIf(!AVAILABLE) integration suite, the capture smoke and all Windows-only cases skip. Assumption: ubuntu-latest has no ffmpeg on PATH (if it does, it is the apt 6.x build that ci.yml deliberately avoids, per ci.yml:32-35). The release is separately gated on green CI, so this is a second gate that checks much less than it appears to.

    Trigger: Read the job log of a publish run: integration suites show as skipped.

    Fix: Either reuse ci.yml's pinned FFmpeg 8 steps and set REQUIRE_FFMPEG=1, or rename the step to say it is a unit-test sanity check and require the CI run for the same SHA to be green before the publish job (check-runs API).

  • wgcRecorder process tests assert frame counts against wall-clock sleeps
    Where: src/__tests__/integration/wgcRecorder.test.ts:146, src/__tests__/integration/wgcRecorder.test.ts:152, src/__tests__/integration/wgcRecorder.test.ts:153, src/__tests__/integration/wgcRecorder.test.ts:215, src/__tests__/integration/wgcRecorder.test.ts:221

    At fps: 10 (line 118) the first case does await sleep(1000), writes q, then expects frames >= 8 and <= 16. The count depends on how long the test process's 1000 ms timer really takes and on child start-up; a timer that fires 700 ms late on a loaded runner yields 17 or more frames. The slow-encoder case sleeps 1200 ms and expects < 10. These suites have no retry, unlike captureSmoke.test.ts:42. It passed in this run; the concern is the hosted Windows runners, which the repo's own comments describe as loaded (captureSmoke.test.ts:21).

    Trigger: Run the suite while the machine is under heavy CPU load (for example alongside the editing integration suite on a 2-core runner).

    Fix: Make the assertion relative to measured time: record t0 when started() resolves and t1 just before writing q, then expect frames within fps * (t1 - t0) / 1000 plus or minus a margin; for the drop test, compare against frames due rather than a constant.

  • The full eval oracle run is never executed in CI; vitest covers 3 of 10 tasks
    Where: evals/oracle.test.ts:53, evals/oracle.test.ts:66, evals/run.ts:76, evals/tasks.ts:35, package.json:32

    evals/run.ts describes oracle mode as the self-check that "catches handler regressions" and "exits non-zero on any failure" (run.ts:10-12, 76-77), but no workflow runs npm run eval (no match for it under .github/workflows/). The only automated use is evals/oracle.test.ts, which runs redact-api-key, cut-dead-air and a negative media-info case. The oracle calls and outcome checks of the other seven tasks (export_gif under 2 MB, screen_diff, trim, contact_sheet, extract_audio, clip, speed) are not exercised anywhere.

    Trigger: Break outputOf or the outputs key in clip; npm test stays green.

    Fix: Run all tasks in oracle.test.ts (runSuite(TASKS, oracleAgent, ...), the fixtures are tiny), or add npm run build && npm run eval to the ffmpeg leg of ci.yml.

Acceptance criteria

  • Every item above is fixed or closed with a reason
  • npm test passes

Getting started

  • Relevant files: vitest.config.ts, src/__tests__/editTool.test.ts, src/__tests__/argPathsCoverage.test.ts, src/__tests__/schemaParity.test.ts, src/__tests__/color.test.ts, src/__tests__/deleteRecording.test.ts, src/__tests__/integration/entryStdio.test.ts, src/__tests__/entryCli.test.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 b8156ef. Severity: low. Effort: M. audit-key: testing|vitest.config.ts|coverage.thresholds.trail

Langage dominant
TypeScript
Étoiles
1
Forks
4
Merge moyen
3 j 4 h
PR mergées (30 j)
4

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de TMHSDigital/screencast-mcp

Toutes les issues de TMHSDigital/screencast-mcp

Issues similaires

Plus d'issues TypeScript

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.