Skip to content

Commit

Permalink
fix(types): do not require @types/node because of puppeteer types
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdbradley committed Sep 17, 2020
1 parent eb02517 commit 1a907f7
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions src/testing/puppeteer/puppeteer-declarations.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -10,7 +17,7 @@ export interface NewE2EPageOptions extends puppeteer.NavigationOptions {

type Omit<T, K> = Pick<T, Exclude<keyof T, K>>;
type PuppeteerPage = Omit<
puppeteer.Page,
Page,
| 'bringToFront'
| 'browser'
| 'screenshot'
Expand Down Expand Up @@ -120,15 +127,15 @@ 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<puppeteer.Response | null>;
goTo(url: string, options?: NavigationOptions): Promise<Response | null>;

/**
* Instead of testing a url directly, html content can be mocked using
* `page.setContent(html)`. A shortcut to `page.setContent(html)` is to set
* the `html` option when creating a new page, such as
* `const page = await newE2EPage({ html })`.
*/
setContent(html: string, options?: puppeteer.NavigationOptions): Promise<void>;
setContent(html: string, options?: NavigationOptions): Promise<void>;

/**
* Used to test if an event was, or was not dispatched. This method
Expand Down Expand Up @@ -162,9 +169,9 @@ export interface E2EPageInternal extends E2EPage {
_e2eElements: E2EElementInternal[];
_e2eEvents: Map<number, WaitForEvent>;
_e2eEventIds: number;
_e2eGoto(url: string, options?: Partial<puppeteer.NavigationOptions>): Promise<puppeteer.Response | null>;
_e2eClose(options?: puppeteer.PageCloseOptions): Promise<void>;
screenshot(options?: puppeteer.ScreenshotOptions): Promise<Buffer>;
_e2eGoto(url: string, options?: Partial<NavigationOptions>): Promise<Response | null>;
_e2eClose(options?: PageCloseOptions): Promise<void>;
screenshot(options?: PuppeteerScreenshotOptions): Promise<Buffer>;
}

export interface E2EElement {
Expand Down Expand Up @@ -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<void>;
click(options?: ClickOptions): Promise<void>;

/**
* Find a child element that matches the selector, which is the same as
Expand Down

0 comments on commit 1a907f7

Please sign in to comment.