Skip to content

Commit

Permalink
Permit better backwards compatability
Browse files Browse the repository at this point in the history
- Offer better compatability between Puppeteer 5 and 10 for projects
  that cannot upgrade
  • Loading branch information
rwaskiewicz committed Jun 25, 2021
1 parent 63cc794 commit d01af05
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions src/testing/puppeteer/puppeteer-declarations.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,36 @@
import type { EventInitDict, EventSpy, ScreenshotDiff, ScreenshotOptions } from '@stencil/core/internal';
import type {
ClickOptions,
HTTPResponse,
HTTPResponse as PuppeteerHTTPResponse,
Page,
ScreenshotOptions as PuppeteerScreenshotOptions,
WaitForOptions,
} from 'puppeteer';

/**
* This type helps with declaration merging as a part of Stencil's migration from Puppeteer v5.4.3 to v10.0.0. In
* v5.4.3, `HttpResponse` was an interface whereas v10.0.0 declares it as a class. It is redeclared here to help teams
* migrate to a newer version of Stencil minor version without requiring a Puppeteer upgrade. This type should be
* removed as a part of the Stencil 3.0 release.
*/
export type HTTPResponse = PuppeteerHTTPResponse;

/**
* These types help with declaration merging as a part of Stencil's migration from Puppeteer v5.4.3 to v10.0.0. In
* v10.0.0, `WaitForOptions` is a renamed version of `NavigationOptions` from v5.4.3, who has had its type hierarchy
* flattened.
*
* See {@link https://github.com/DefinitelyTyped/DefinitelyTyped/blob/8290e943f6b398acf39ee1b2e486824144e15bc8/types/puppeteer/index.d.ts#L605-L622}
* for the v5.4.3 types.
*
* These types are redeclared here to help teams migrate to a newer version of Stencil minor version without requiring a
* Puppeteer upgrade. This type should be removed as a part of the Stencil 3.0 release.
*/
export type PuppeteerLifeCycleEvent = 'load' | 'domcontentloaded' | 'networkidle0' | 'networkidle2';
export interface WaitForOptions {
timeout?: number;
waitUntil?: PuppeteerLifeCycleEvent | PuppeteerLifeCycleEvent[];
}

/**
* This type was once exported by Puppeteer, but has since moved to an object literal in (Puppeteer’s) native types.
* Re-create it here as a named type to use across multiple Stencil-related testing files.
Expand Down

0 comments on commit d01af05

Please sign in to comment.