Skip to content

Commit cf6a450

Browse files
feat(testing): expose captureBeyondViewport in pageCompareScreenshot (#5828)
1 parent b6d2404 commit cf6a450

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

src/declarations/stencil-private.ts

+6
Original file line numberDiff line numberDiff line change
@@ -1848,6 +1848,12 @@ export interface ScreenshotOptions {
18481848
* more sensitive. Defaults to the testing config `pixelmatchThreshold` value;
18491849
*/
18501850
pixelmatchThreshold?: number;
1851+
/**
1852+
* Capture the screenshot beyond the viewport.
1853+
*
1854+
* @defaultValue `false` if there is no `clip`. `true` otherwise.
1855+
*/
1856+
captureBeyondViewport?: boolean;
18511857
}
18521858

18531859
export interface ScreenshotBoundingBox {

src/testing/puppeteer/puppeteer-screenshot.ts

+4
Original file line numberDiff line numberDiff line change
@@ -159,13 +159,17 @@ export function createPuppeteerScreenshotOptions(
159159
};
160160

161161
if (opts.clip) {
162+
puppeteerOpts.captureBeyondViewport =
163+
typeof opts.captureBeyondViewport === 'boolean' ? opts.captureBeyondViewport : true;
162164
puppeteerOpts.clip = {
163165
x: opts.clip.x,
164166
y: opts.clip.y,
165167
width: opts.clip.width,
166168
height: opts.clip.height,
167169
};
168170
} else {
171+
puppeteerOpts.captureBeyondViewport =
172+
typeof opts.captureBeyondViewport === 'boolean' ? opts.captureBeyondViewport : false;
169173
puppeteerOpts.clip = {
170174
x: 0,
171175
y: 0,

src/testing/puppeteer/test/puppeteer-screenshot.spec.ts

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ describe('Puppeteer Screenshot', () => {
1111
width: 800,
1212
height: 600,
1313
});
14+
expect(options.captureBeyondViewport).toBe(false);
1415
});
1516

1617
it('should use clip options if provided', () => {
@@ -32,6 +33,7 @@ describe('Puppeteer Screenshot', () => {
3233
width: 100,
3334
height: 200,
3435
});
36+
expect(options.captureBeyondViewport).toBe(true);
3537
});
3638
});
3739
});

0 commit comments

Comments
 (0)