Skip to content

Commit d6a5df8

Browse files
committed
take screenshots in noop.js
1 parent c25c0ec commit d6a5df8

File tree

1 file changed

+16
-28
lines changed

1 file changed

+16
-28
lines changed

scripts/pit/its/noop.js

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,23 @@
1-
const { chromium } = require('playwright');
21

3-
let headless = false, host = 'localhost', port = '8080', mode = false;
4-
process.argv.forEach(a => {
5-
if (/^--headless/.test(a)) {
6-
headless = true;
7-
} else if (/^--port=/.test(a)) {
8-
port = a.split('=')[1];
9-
} else if (/^--mode=/.test(a)) {
10-
mode = a.split('=')[1];
11-
}
12-
});
2+
const {log, warn, args, createPage, closePage, takeScreenshot, waitForServerReady} = require('./test-utils');
133

144
(async () => {
15-
const browser = await chromium.launch({
16-
headless: headless,
17-
chromiumSandbox: false
18-
});
19-
const sleep = ms => new Promise(r => setTimeout(r, ms));
20-
21-
const context = await browser.newContext();
22-
23-
const page = await context.newPage();
24-
page.on('console', msg => console.log("> CONSOLE:", (msg.text() + ' - ' + msg.location().url).replace(/\s+/g, ' ')));
25-
page.on('pageerror', err => console.log("> PAGEERROR:", ('' + err).replace(/\s+/g, ' ')));
26-
27-
await page.goto(`http://${host}:${port}/`);
5+
const arg = args();
6+
const page = await createPage(arg.headless, arg.ignoreHTTPSErrors);
7+
await waitForServerReady(page, arg.url);
288

299
await page.waitForSelector('#outlet > * > *:not(style):not(script)');
30-
const txt = await page.locator('#outlet').first().innerHTML();
31-
console.log('\n====== PAGE CONTENT ======\n', txt, '\n====== END ======\n');
10+
await takeScreenshot(page, __filename, 'view-loaded');
11+
try {
12+
const txt = await page.locator('#outlet').first().innerHTML();
13+
log("====== PAGE CONTENT ======");
14+
out(txt);
15+
log("====== END ======");
16+
} catch (error) {
17+
const txt = await page.locator('html').innerHTML();
18+
warn(`> PAGEERROR: ${txt}`);
19+
throw error;
20+
}
3221

33-
await context.close();
34-
await browser.close();
22+
await closePage(page);
3523
})();

0 commit comments

Comments
 (0)