Sitelet https://github.com/lightspeedwp/.github/issues/3482
Skip to content

test: Jest suite writes into the working tree (tracked results file and report outputs) #3482

Description

@eleshar

Problem

Running the Jest suite (npx jest --config .jest.config.cjs) modifies the working tree:

  • Modifies a tracked file: scripts/automation/__tests__/performance/results-phase-2b.json, written by phase-2b-validation.test.js (line 242).
  • Creates untracked files: .github/reports/metrics/collection-summary-<date>.json via scripts/workflows/metrics-collection-orchestrator.cjs (exercised by metrics-collection-orchestrator.test.js), and .github/reports/changelog-metrics/<date>.json via agents/changelog-agent/includes/metricsSnapshotBuilder.cjs (default metricsDir, lines 180/226).

A developer running the suite and then git add -A or git commit -a commits test output, and CI runs are not hermetic.

Change

  • Tests write only to os.tmpdir() (for example fs.mkdtempSync), or inject an output directory into the module under test.
  • results-phase-2b.json: if it is a committed baseline, the test should read it and never write it; if it is output, move it to a temp dir and untrack it.
  • Add a guard: after the suite, git status --porcelain must be empty. Wire this into the test workflow planned in fix(ci): no workflow runs the Jest suite, so test regressions merge green #3479.

Acceptance

  • npx jest --config .jest.config.cjs && git status --porcelain prints nothing on a clean checkout.

Found while verifying #3477/#3478.

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

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions