-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap.js
35 lines (32 loc) · 992 Bytes
/
bootstrap.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
const { chromium, firefox, webkit } = require('playwright');
before(async function () {
if (global.browser === undefined) {
const browserName = process.env.BROWSER || 'chromium';
const browserType = {
undefined: chromium,
chromium,
firefox,
webkit
}[browserName];
global.browser = await browserType.launch({
headless: process.env.HEAD !== 'true' /* ,devtools: true */
});
const version = global.browser.version();
console.log(`Test running on ${browserName} ${version}`);
global.ctx = await global.browser.newContext();
// Default timeout of 5 seconds
global.ctx.setDefaultTimeout(20_000);
}
});
after(async function () {
// Don't close the browser on watch mode
if (process.env.WATCH !== 'true') {
await global.browser.close();
}
});
global.closePage = async function (page) {
// Don't close page on watch mode
if (page !== undefined && process.env.WATCH !== 'true') {
await page.close();
}
};