diff --git a/src/declarations/stencil-private.ts b/src/declarations/stencil-private.ts index faa46e0d023..2809e873ccc 100644 --- a/src/declarations/stencil-private.ts +++ b/src/declarations/stencil-private.ts @@ -1848,6 +1848,12 @@ export interface ScreenshotOptions { * more sensitive. Defaults to the testing config `pixelmatchThreshold` value; */ pixelmatchThreshold?: number; + /** + * Capture the screenshot beyond the viewport. + * + * @defaultValue `false` if there is no `clip`. `true` otherwise. + */ + captureBeyondViewport?: boolean; } export interface ScreenshotBoundingBox { diff --git a/src/testing/puppeteer/puppeteer-screenshot.ts b/src/testing/puppeteer/puppeteer-screenshot.ts index 7f2e33e5694..1aa6f7e99f9 100644 --- a/src/testing/puppeteer/puppeteer-screenshot.ts +++ b/src/testing/puppeteer/puppeteer-screenshot.ts @@ -159,6 +159,8 @@ export function createPuppeteerScreenshotOptions( }; if (opts.clip) { + puppeteerOpts.captureBeyondViewport = + typeof opts.captureBeyondViewport === 'boolean' ? opts.captureBeyondViewport : true; puppeteerOpts.clip = { x: opts.clip.x, y: opts.clip.y, @@ -166,6 +168,8 @@ export function createPuppeteerScreenshotOptions( height: opts.clip.height, }; } else { + puppeteerOpts.captureBeyondViewport = + typeof opts.captureBeyondViewport === 'boolean' ? opts.captureBeyondViewport : false; puppeteerOpts.clip = { x: 0, y: 0, diff --git a/src/testing/puppeteer/test/puppeteer-screenshot.spec.ts b/src/testing/puppeteer/test/puppeteer-screenshot.spec.ts index c481655ee5d..3b290ed29aa 100644 --- a/src/testing/puppeteer/test/puppeteer-screenshot.spec.ts +++ b/src/testing/puppeteer/test/puppeteer-screenshot.spec.ts @@ -11,6 +11,7 @@ describe('Puppeteer Screenshot', () => { width: 800, height: 600, }); + expect(options.captureBeyondViewport).toBe(false); }); it('should use clip options if provided', () => { @@ -32,6 +33,7 @@ describe('Puppeteer Screenshot', () => { width: 100, height: 200, }); + expect(options.captureBeyondViewport).toBe(true); }); }); });