From 5f12917d47004927b00c1221b42d3f43d725817c Mon Sep 17 00:00:00 2001 From: Toby Hamand Date: Tue, 21 Aug 2018 16:37:40 +0100 Subject: [PATCH] [puppeteer] add option defaultViewport to launchOptions interface to adhere to official docs: https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md\#puppeteerlaunchoptions --- types/puppeteer/index.d.ts | 29 +++++++++++++++++++++++++++++ types/puppeteer/puppeteer-tests.ts | 1 + 2 files changed, 30 insertions(+) diff --git a/types/puppeteer/index.d.ts b/types/puppeteer/index.d.ts index a5e85f802e..fc5b45871b 100644 --- a/types/puppeteer/index.d.ts +++ b/types/puppeteer/index.d.ts @@ -1647,6 +1647,35 @@ export interface LaunchOptions { * Useful so that you can see what is going on. */ slowMo?: number; + /** + * Sets a consistent viewport for each page. Defaults to an 800x600 viewport. null disables the default viewport. + */ + defaultViewport?: { + /** + * page width in pixels. + */ + width?: number; + /** + * page height in pixels. + */ + height?: number; + /** + * Specify device scale factor (can be thought of as dpr). Defaults to 1. + */ + deviceScaleFactor?: number; + /** + * Whether the meta viewport tag is taken into account. Defaults to false. + */ + isMobile?: boolean; + /** + * Specifies if viewport supports touch events. Defaults to false. + */ + hasTouch?: boolean; + /** + * Specifies if viewport is in landscape mode. Defaults to false. + */ + isLandscape?: boolean; + }; /** * Additional arguments to pass to the Chromium instance. List of Chromium * flags can be found here. diff --git a/types/puppeteer/puppeteer-tests.ts b/types/puppeteer/puppeteer-tests.ts index e883157fec..2db92a9171 100644 --- a/types/puppeteer/puppeteer-tests.ts +++ b/types/puppeteer/puppeteer-tests.ts @@ -167,6 +167,7 @@ puppeteer.launch().then(async browser => { '--no-sandbox', '--disable-setuid-sandbox', ], + defaultViewport: { width: 800, height: 600 }, handleSIGINT: true, handleSIGHUP: true, handleSIGTERM: true,