Skip to content

Commit 685f96c

Browse files
committed
Permit better backwards compatability
- Offer better compatability between Puppeteer 5 and 10 for projects that cannot upgrade
1 parent 065624e commit 685f96c

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

src/testing/puppeteer/puppeteer-declarations.ts

+26-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,36 @@
11
import type { EventInitDict, EventSpy, ScreenshotDiff, ScreenshotOptions } from '@stencil/core/internal';
22
import type {
33
ClickOptions,
4-
HTTPResponse,
4+
HTTPResponse as PuppeteerHTTPResponse,
55
Page,
66
ScreenshotOptions as PuppeteerScreenshotOptions,
7-
WaitForOptions,
87
} from 'puppeteer';
98

9+
/**
10+
* This type helps with declaration merging as a part of Stencil's migration from Puppeteer v5.4.3 to v10.0.0. In
11+
* v5.4.3, `HttpResponse` was an interface whereas v10.0.0 declares it as a class. It is redeclared here to help teams
12+
* migrate to a newer version of Stencil minor version without requiring a Puppeteer upgrade. This type should be
13+
* removed as a part of the Stencil 3.0 release.
14+
*/
15+
export type HTTPResponse = PuppeteerHTTPResponse;
16+
17+
/**
18+
* These types help with declaration merging as a part of Stencil's migration from Puppeteer v5.4.3 to v10.0.0. In
19+
* v10.0.0, `WaitForOptions` is a renamed version of `NavigationOptions` from v5.4.3, who has had its type hierarchy
20+
* flattened.
21+
*
22+
* See {@link https://github.com/DefinitelyTyped/DefinitelyTyped/blob/8290e943f6b398acf39ee1b2e486824144e15bc8/types/puppeteer/index.d.ts#L605-L622}
23+
* for the v5.4.3 types.
24+
*
25+
* These types are redeclared here to help teams migrate to a newer version of Stencil minor version without requiring a
26+
* Puppeteer upgrade. This type should be removed as a part of the Stencil 3.0 release.
27+
*/
28+
export type PuppeteerLifeCycleEvent = 'load' | 'domcontentloaded' | 'networkidle0' | 'networkidle2';
29+
export interface WaitForOptions {
30+
timeout?: number;
31+
waitUntil?: PuppeteerLifeCycleEvent | PuppeteerLifeCycleEvent[];
32+
}
33+
1034
/**
1135
* This type was once exported by Puppeteer, but has since moved to an object literal in (Puppeteer’s) native types.
1236
* Re-create it here as a named type to use across multiple Stencil-related testing files.

0 commit comments

Comments
 (0)