diff --git a/src/declarations/rindo-private.ts b/src/declarations/rindo-private.ts index 6d8473e2..b37b2c53 100644 --- a/src/declarations/rindo-private.ts +++ b/src/declarations/rindo-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 24c4354a..a334d243 100644 --- a/src/testing/puppeteer/puppeteer-screenshot.ts +++ b/src/testing/puppeteer/puppeteer-screenshot.ts @@ -157,6 +157,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, @@ -164,6 +166,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 c481655e..3b290ed2 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); }); }); });