From 1a907f784f58463cfe52f87518f1a1d38a2908e5 Mon Sep 17 00:00:00 2001 From: Adam Bradley Date: Thu, 17 Sep 2020 11:36:43 -0500 Subject: [PATCH] fix(types): do not require @types/node because of puppeteer types --- .../puppeteer/puppeteer-declarations.ts | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/testing/puppeteer/puppeteer-declarations.ts b/src/testing/puppeteer/puppeteer-declarations.ts index 1f76e975acc..158db33a2d3 100644 --- a/src/testing/puppeteer/puppeteer-declarations.ts +++ b/src/testing/puppeteer/puppeteer-declarations.ts @@ -1,7 +1,14 @@ import type { EventInitDict, EventSpy, ScreenshotDiff, ScreenshotOptions } from '@stencil/core/internal'; -import type * as puppeteer from 'puppeteer'; - -export interface NewE2EPageOptions extends puppeteer.NavigationOptions { +import type { + ClickOptions, + NavigationOptions, + Page, + PageCloseOptions, + ScreenshotOptions as PuppeteerScreenshotOptions, + Response, +} from 'puppeteer'; + +export interface NewE2EPageOptions extends NavigationOptions { url?: string; html?: string; failOnConsoleError?: boolean; @@ -10,7 +17,7 @@ export interface NewE2EPageOptions extends puppeteer.NavigationOptions { type Omit = Pick>; type PuppeteerPage = Omit< - puppeteer.Page, + Page, | 'bringToFront' | 'browser' | 'screenshot' @@ -120,7 +127,7 @@ export interface E2EPage extends PuppeteerPage { * a localhost address. A shortcut to `page.goto(url)` is to set the `url` option * when creating a new page, such as `const page = await newE2EPage({ url })`. */ - goTo(url: string, options?: puppeteer.NavigationOptions): Promise; + goTo(url: string, options?: NavigationOptions): Promise; /** * Instead of testing a url directly, html content can be mocked using @@ -128,7 +135,7 @@ export interface E2EPage extends PuppeteerPage { * the `html` option when creating a new page, such as * `const page = await newE2EPage({ html })`. */ - setContent(html: string, options?: puppeteer.NavigationOptions): Promise; + setContent(html: string, options?: NavigationOptions): Promise; /** * Used to test if an event was, or was not dispatched. This method @@ -162,9 +169,9 @@ export interface E2EPageInternal extends E2EPage { _e2eElements: E2EElementInternal[]; _e2eEvents: Map; _e2eEventIds: number; - _e2eGoto(url: string, options?: Partial): Promise; - _e2eClose(options?: puppeteer.PageCloseOptions): Promise; - screenshot(options?: puppeteer.ScreenshotOptions): Promise; + _e2eGoto(url: string, options?: Partial): Promise; + _e2eClose(options?: PageCloseOptions): Promise; + screenshot(options?: PuppeteerScreenshotOptions): Promise; } export interface E2EElement { @@ -215,7 +222,7 @@ export interface E2EElement { * then uses `page.mouse` to click in the center of the element. * Please see the puppeteer docs for more information. */ - click(options?: puppeteer.ClickOptions): Promise; + click(options?: ClickOptions): Promise; /** * Find a child element that matches the selector, which is the same as