Skip to content

Commit

Permalink
cleanup injected js
Browse files Browse the repository at this point in the history
  • Loading branch information
greggman committed Jul 2, 2024
1 parent 91d4ea7 commit 6dac51e
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions test/puppeteer.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ async function test(port) {
for (const {url, js, screenshot} of testPages) {
waitingPromiseInfo = makePromiseInfo();
console.log(`===== [ ${url} ] =====`);
if (js) {
await page.evaluateOnNewDocument(js);
}
const id = js
? await page.evaluateOnNewDocument(js)
: undefined;
await page.goto(url);
await page.waitForNetworkIdle();
if (js) {
Expand All @@ -93,6 +93,9 @@ async function test(port) {
const path = `${dir}/${name}.png`;
await page.screenshot({path});
}
if (id) {
await page.removeScriptToEvaluateOnNewDocument(id.identifier);
}
}

await browser.close();
Expand Down

0 comments on commit 6dac51e

Please sign in to comment.