update puppeteer to use setContent with wait and housekeeping the declaration files

This commit is contained in:
Yanzhen Yu
2026-04-01 12:00:00 +08:00
parent 270c9e48aa
commit 9a4640fa98
4 changed files with 6 additions and 44 deletions

23
index.d.ts vendored
View File

@@ -4,26 +4,3 @@ declare namespace mitt {
(all?: { [key: string]: Array<Handler> }): Emitter;
}
}
declare module 'delegated-events' {
type EventHandler = (event: Event) => any;
type EventListenerOptions = {
capture?: boolean;
document?: Document;
};
export function on(
name: string,
selector: string,
handler: EventHandler,
options?: EventListenerOptions,
): void;
export function off(
name: string,
selector: string,
handler: EventHandler,
options?: EventListenerOptions,
): void;
export function fire(target: EventTarget, name: string, detail?: any): void;
}

View File

@@ -37,7 +37,6 @@
"@types/mocha": "^5.2.5",
"@types/node": "^10.11.7",
"@types/puppeteer": "^1.9.0",
"@types/rewire": "^2.5.28",
"chai": "^4.2.0",
"jest-snapshot": "^23.6.0",
"mocha": "^5.2.0",

19
test.d.ts vendored
View File

@@ -1,22 +1,3 @@
declare module 'rollup-plugin-typescript' {
function typescript(): any;
export = typescript;
}
declare module 'rollup-plugin-node-resolve' {
function resolve(): any;
export = resolve;
}
declare module 'rollup-plugin-terser' {
export function terser(options?: any): any;
}
declare module 'rollup-plugin-postcss' {
function postcss(options?: any): any;
export = postcss;
}
declare module 'jest-snapshot' {
export class SnapshotState {
constructor(testFile: string, options: any);

View File

@@ -214,7 +214,12 @@ describe('record integration tests', () => {
it('can record node mutations', async () => {
const page: puppeteer.Page = await this.browser.newPage();
await page.goto(`data:text/html,${getHtml.call(this, 'select2.html')}`, {
await page.goto('about:blank');
// FIXME: use setContent directly when @types/puppeteer update
const setContent = async (html: string, options: any) => {
return page.setContent.call(page, html, options);
};
await setContent(getHtml.call(this, 'select2.html'), {
waitUntil: 'networkidle0',
});