mirror of
https://github.com/wavetermdev/xterm.js.git
synced 2026-08-05 13:43:48 -07:00
feat(test): use common function to launch the browser
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
import { pollFor, openTerminal, getBrowserType } from './TestUtils';
|
||||
import { pollFor, openTerminal, launchBrowser } from './TestUtils';
|
||||
import { Browser, Page } from 'playwright';
|
||||
|
||||
const APP = 'http://127.0.0.1:3001/test';
|
||||
@@ -15,10 +15,7 @@ const height = 600;
|
||||
|
||||
describe('CharWidth Integration Tests', function(): void {
|
||||
before(async function(): Promise<any> {
|
||||
const browserType = getBrowserType();
|
||||
browser = await browserType.launch({
|
||||
headless: process.argv.indexOf('--headless') !== -1
|
||||
});
|
||||
browser = await launchBrowser();
|
||||
page = await (await browser.newContext()).newPage();
|
||||
await page.setViewportSize({ width, height });
|
||||
await page.goto(APP);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
import { assert } from 'chai';
|
||||
import { pollFor, openTerminal, getBrowserType } from './TestUtils';
|
||||
import { pollFor, openTerminal, getBrowserType, launchBrowser } from './TestUtils';
|
||||
import { Browser, Page } from 'playwright';
|
||||
import { IRenderDimensions } from 'browser/renderer/Types';
|
||||
|
||||
@@ -21,9 +21,7 @@ describe('InputHandler Integration Tests', function(): void {
|
||||
before(async function(): Promise<any> {
|
||||
const browserType = getBrowserType();
|
||||
isChromium = browserType.name() === 'chromium';
|
||||
browser = await browserType.launch({
|
||||
headless: process.argv.indexOf('--headless') !== -1
|
||||
});
|
||||
browser = await launchBrowser();
|
||||
page = await (await browser.newContext()).newPage();
|
||||
await page.setViewportSize({ width, height });
|
||||
await page.goto(APP);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
import { pollFor, writeSync, openTerminal, getBrowserType } from './TestUtils';
|
||||
import { pollFor, writeSync, openTerminal, getBrowserType, launchBrowser } from './TestUtils';
|
||||
import { Browser, Page } from 'playwright';
|
||||
|
||||
const APP = 'http://127.0.0.1:3001/test';
|
||||
@@ -211,9 +211,7 @@ describe('Mouse Tracking Tests', async () => {
|
||||
const itMouse = isChromium ? it : it.skip;
|
||||
|
||||
before(async function(): Promise<void> {
|
||||
browser = await browserType.launch({
|
||||
headless: process.argv.indexOf('--headless') !== -1
|
||||
});
|
||||
browser = await launchBrowser();
|
||||
page = await (await browser.newContext()).newPage();
|
||||
await page.setViewportSize({ width, height });
|
||||
});
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
import { assert } from 'chai';
|
||||
import { writeSync, openTerminal, getBrowserType } from './TestUtils';
|
||||
import { writeSync, openTerminal, launchBrowser } from './TestUtils';
|
||||
import { Browser, Page } from 'playwright';
|
||||
|
||||
const APP = 'http://127.0.0.1:3001/test';
|
||||
@@ -16,10 +16,7 @@ const height = 600;
|
||||
|
||||
describe('Parser Integration Tests', function (): void {
|
||||
before(async function (): Promise<any> {
|
||||
const browserType = getBrowserType();
|
||||
browser = await browserType.launch({
|
||||
headless: process.argv.indexOf('--headless') !== -1
|
||||
});
|
||||
browser = await launchBrowser();
|
||||
page = await (await browser.newContext()).newPage();
|
||||
await page.setViewportSize({ width, height });
|
||||
await page.goto(APP);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
import { assert } from 'chai';
|
||||
import { pollFor, timeout, writeSync, openTerminal, getBrowserType } from './TestUtils';
|
||||
import { pollFor, timeout, writeSync, openTerminal, launchBrowser } from './TestUtils';
|
||||
import { Browser, Page } from 'playwright';
|
||||
|
||||
const APP = 'http://127.0.0.1:3001/test';
|
||||
@@ -16,10 +16,7 @@ const height = 600;
|
||||
|
||||
describe('API Integration Tests', function(): void {
|
||||
before(async () => {
|
||||
const browserType = getBrowserType();
|
||||
browser = await browserType.launch({
|
||||
headless: process.argv.indexOf('--headless') !== -1
|
||||
});
|
||||
browser = await launchBrowser();
|
||||
page = await (await browser.newContext()).newPage();
|
||||
await page.setViewportSize({ width, height });
|
||||
});
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user