Skip to content

Commit c3769fd

Browse files
committed
test(capture-kit): encode solid test PNGs unfiltered to stay inside the unit budget
The 375x812-vs-1080x2340 comparison spent ~0.8s of its wall clock encoding the capture with pngjs' default scanline filters, which for a solid fill buy no compression and only burn CPU under coverage instrumentation. On the Coverage lane it crossed the 2x slow-test enforce line and vitest's 5s timeout (run 39928270661). filterType 0 is a lossless choice the decoder inverts, so every compared pixel is identical.
1 parent 28470ff commit c3769fd

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

‎packages/capture-kit/src/screenshot-diff.test.ts‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,13 @@ function tmpDir(): string {
1212
return mkdtempForTestSync('agent-device-screenshot-diff-');
1313
}
1414

15-
/** Create a solid-color PNG and write it to disk. */
15+
/**
16+
* Create a solid-color PNG and write it to disk. `filterType: 0` skips the
17+
* per-scanline deflate filters: for a solid image they only make the encoder
18+
* slower (the full-resolution cases spent ~0.8s encoding under coverage).
19+
* Filtering is a lossless transform the decoder inverts, so the decoded
20+
* pixels — everything these tests compare — are unchanged.
21+
*/
1622
function writeSolidPng(
1723
filePath: string,
1824
width: number,
@@ -26,7 +32,7 @@ function writeSolidPng(
2632
png.data[i + 2] = color.b;
2733
png.data[i + 3] = 255;
2834
}
29-
fs.writeFileSync(filePath, PNG.sync.write(png));
35+
fs.writeFileSync(filePath, PNG.sync.write(png, { filterType: 0 }));
3036
}
3137

3238
/** Encode a solid-color JPEG, so a test can hand the comparison a lossy container. */

0 commit comments

Comments
 (0)