2020-04-08 18:47:46 +03:00
|
|
|
//@ts-check
|
2020-07-29 20:38:23 +03:00
|
|
|
const {chromium, webkit, firefox} = require("playwright");
|
|
|
|
const http = require('http');
|
|
|
|
|
|
|
|
const server = http.createServer((req, res) => {
|
|
|
|
res.writeHead(200);
|
|
|
|
res.end('Hello, world');
|
|
|
|
});
|
2020-04-08 18:47:46 +03:00
|
|
|
|
2020-06-16 07:50:45 +03:00
|
|
|
const headless = !process.env.HEADFUL;
|
|
|
|
|
2020-07-29 20:38:23 +03:00
|
|
|
async function checkBrowser(browserType) {
|
2020-07-27 23:48:26 +03:00
|
|
|
try {
|
2020-07-29 20:38:23 +03:00
|
|
|
console.log(`Running ${browserType.name()}`);
|
|
|
|
const browser = await browserType.launch({ headless });
|
2020-07-27 23:48:26 +03:00
|
|
|
const page = await browser.newPage();
|
2020-07-29 20:38:23 +03:00
|
|
|
await page.goto('http://localhost:8080');
|
|
|
|
console.log(`- ${browserType.name()}:`, await page.evaluate(() => ({
|
2020-07-27 23:48:26 +03:00
|
|
|
width: document.documentElement.clientWidth,
|
|
|
|
clientHeight: document.documentElement.clientHeight
|
|
|
|
})));
|
|
|
|
await browser.close();
|
2020-07-29 20:38:23 +03:00
|
|
|
console.log(`SUCCESS running ${browserType.name()}`);
|
|
|
|
return true;
|
2020-07-27 23:48:26 +03:00
|
|
|
} catch (e) {
|
2020-07-29 20:38:23 +03:00
|
|
|
console.log(`FAILED running ${browserType.name()}`);
|
2020-07-27 23:48:26 +03:00
|
|
|
console.error(e);
|
2020-07-29 20:38:23 +03:00
|
|
|
return false;
|
2020-07-27 23:48:26 +03:00
|
|
|
}
|
2020-04-08 18:47:46 +03:00
|
|
|
}
|
|
|
|
|
2020-07-29 20:38:23 +03:00
|
|
|
server.listen(8080, async () => {
|
|
|
|
let success = true;
|
|
|
|
success = (await checkBrowser(chromium)) && success;
|
|
|
|
success = (await checkBrowser(webkit)) && success;
|
|
|
|
success = (await checkBrowser(firefox)) && success;
|
|
|
|
server.close();
|
|
|
|
// in case some browsers failed to close - exit process.
|
|
|
|
process.exit(success ? 0 : 1);
|
|
|
|
});
|