Manifest
Merging the manifests of a run
A run usually produces several manifests.
A run usually produces several manifests. mergeManifests concatenates them into one list keyed by screenshot name, test file, platform and renderer, with a later CI attempt winning over an earlier one, and prepares what an approval tool needs:
import { mergeManifests, selectEntries } from 'visual-regression-manifest';
const run = mergeManifests(
found.map(({ file, manifest }) => ({ manifest, label: file })),
{ headSha: pr.head.sha, buildId: workflowRun.id, repositoryName: 'acme/app' },
);
run.counts; // { passed: 40, failed: 2, 'missing-baseline': 1, created: 0, updated: 0, approved: 0 }
run.needsHuman; // the failed and missing-baseline entries
run.warnings; // manifests written for another commit/run/repository, renderer fallbacks, unapprovable project roots
for (const {
entry,
repoPaths,
keyHash,
unapprovableReason,
collidesWith,
} of run.needsHuman) {
// repoPaths: baseline/actual/diff relative to the repository root (`null` when they escape it)
// keyHash: a short stable id for buttons and commands
// collidesWith: other entries writing the same baseline file (two platforms, one path)
}
// `/approve-visuals home_#0 "about_#0 (darwin / chrome)"`
const { entries, unknown } = selectEntries(run, { names: ['home_#0'] });
Any object with a manifest property is a source; extra properties (an artifact id, a zip path) come back on MergedEntry.source with their type.