feat(test): use common function to launch the browser

This commit is contained in:
Baptiste Augrain
2021-08-31 12:50:54 +02:00
parent 7068954334
commit 9e40614b5c
14 changed files with 44 additions and 58 deletions
+14
View File
@@ -67,3 +67,17 @@ export function getBrowserType(): playwright.BrowserType<playwright.WebKitBrowse
return browserType;
}
export function launchBrowser() {
const browserType = getBrowserType();
const options: Record<string, unknown> = {
headless: process.argv.includes('--headless'),
}
const index = process.argv.indexOf('--executablePath');
if(index > 0 && process.argv.length > index + 1 && typeof process.argv[index + 1] === 'string') {
options.executablePath = process.argv[index + 1];
}
return browserType.launch(options);
}