Merge branch 'master' into refactor-better-mocha

This commit is contained in:
Daniel Imms
2021-08-31 05:41:17 -07:00
committed by GitHub
14 changed files with 44 additions and 58 deletions
@@ -4,7 +4,7 @@
*/ */
import WebSocket = require('ws'); import WebSocket = require('ws');
import { openTerminal, pollFor, getBrowserType } from '../../../out-test/api/TestUtils'; import { openTerminal, pollFor, launchBrowser } from '../../../out-test/api/TestUtils';
import { Browser, Page } from 'playwright'; import { Browser, Page } from 'playwright';
const APP = 'http://127.0.0.1:3001/test'; const APP = 'http://127.0.0.1:3001/test';
@@ -16,10 +16,7 @@ const height = 600;
describe('AttachAddon', () => { describe('AttachAddon', () => {
before(async function(): Promise<any> { before(async function(): Promise<any> {
const browserType = getBrowserType(); browser = await launchBrowser();
browser = await browserType.launch({
headless: process.argv.includes('--headless')
});
page = await (await browser.newContext()).newPage(); page = await (await browser.newContext()).newPage();
await page.setViewportSize({ width, height }); await page.setViewportSize({ width, height });
}); });
+2 -5
View File
@@ -4,7 +4,7 @@
*/ */
import { assert } from 'chai'; import { assert } from 'chai';
import { openTerminal, getBrowserType } from '../../../out-test/api/TestUtils'; import { openTerminal, launchBrowser } from '../../../out-test/api/TestUtils';
import { Browser, Page } from 'playwright'; import { Browser, Page } from 'playwright';
const APP = 'http://127.0.0.1:3001/test'; const APP = 'http://127.0.0.1:3001/test';
@@ -16,10 +16,7 @@ const height = 768;
describe('FitAddon', () => { describe('FitAddon', () => {
before(async function(): Promise<any> { before(async function(): Promise<any> {
const browserType = getBrowserType(); browser = await launchBrowser();
browser = await browserType.launch({
headless: process.argv.includes('--headless')
});
page = await (await browser.newContext()).newPage(); page = await (await browser.newContext()).newPage();
await page.setViewportSize({ width, height }); await page.setViewportSize({ width, height });
await page.goto(APP); await page.goto(APP);
@@ -6,7 +6,7 @@
import { assert } from 'chai'; import { assert } from 'chai';
import { readFile } from 'fs'; import { readFile } from 'fs';
import { resolve } from 'path'; import { resolve } from 'path';
import { openTerminal, writeSync, getBrowserType } from '../../../out-test/api/TestUtils'; import { openTerminal, writeSync, launchBrowser } from '../../../out-test/api/TestUtils';
import { Browser, Page } from 'playwright'; import { Browser, Page } from 'playwright';
const APP = 'http://127.0.0.1:3001/test'; const APP = 'http://127.0.0.1:3001/test';
@@ -18,10 +18,7 @@ const height = 600;
describe('Search Tests', function(): void { describe('Search Tests', function(): void {
before(async function(): Promise<any> { before(async function(): Promise<any> {
const browserType = getBrowserType(); browser = await launchBrowser();
browser = await browserType.launch({
headless: process.argv.includes('--headless')
});
page = await (await browser.newContext()).newPage(); page = await (await browser.newContext()).newPage();
await page.setViewportSize({ width, height }); await page.setViewportSize({ width, height });
await page.goto(APP); await page.goto(APP);
@@ -4,7 +4,7 @@
*/ */
import { assert } from 'chai'; import { assert } from 'chai';
import { openTerminal, writeSync, getBrowserType } from '../../../out-test/api/TestUtils'; import { openTerminal, writeSync, launchBrowser } from '../../../out-test/api/TestUtils';
import { Browser, Page } from 'playwright'; import { Browser, Page } from 'playwright';
const APP = 'http://127.0.0.1:3001/test'; const APP = 'http://127.0.0.1:3001/test';
@@ -38,10 +38,7 @@ async function testSerializeEquals(writeContent: string, expectedSerialized: str
describe('SerializeAddon', () => { describe('SerializeAddon', () => {
before(async function(): Promise<any> { before(async function(): Promise<any> {
const browserType = getBrowserType(); browser = await launchBrowser();
browser = await browserType.launch({
headless: process.argv.includes('--headless')
});
page = await (await browser.newContext()).newPage(); page = await (await browser.newContext()).newPage();
await page.setViewportSize({ width, height }); await page.setViewportSize({ width, height });
await page.goto(APP); await page.goto(APP);
@@ -4,7 +4,7 @@
*/ */
import { assert } from 'chai'; import { assert } from 'chai';
import { openTerminal, getBrowserType } from '../../../out-test/api/TestUtils'; import { openTerminal, launchBrowser } from '../../../out-test/api/TestUtils';
import { Browser, Page } from 'playwright'; import { Browser, Page } from 'playwright';
const APP = 'http://127.0.0.1:3001/test'; const APP = 'http://127.0.0.1:3001/test';
@@ -16,10 +16,7 @@ const height = 600;
describe('Unicode11Addon', () => { describe('Unicode11Addon', () => {
before(async function(): Promise<any> { before(async function(): Promise<any> {
const browserType = getBrowserType(); browser = await launchBrowser();
browser = await browserType.launch({
headless: process.argv.includes('--headless')
});
page = await (await browser.newContext()).newPage(); page = await (await browser.newContext()).newPage();
await page.setViewportSize({ width, height }); await page.setViewportSize({ width, height });
}); });
@@ -4,7 +4,7 @@
*/ */
import { assert } from 'chai'; import { assert } from 'chai';
import { openTerminal, pollFor, writeSync, getBrowserType } from '../../../out-test/api/TestUtils'; import { openTerminal, pollFor, writeSync, launchBrowser } from '../../../out-test/api/TestUtils';
import { Browser, Page } from 'playwright'; import { Browser, Page } from 'playwright';
const APP = 'http://127.0.0.1:3001/test'; const APP = 'http://127.0.0.1:3001/test';
@@ -16,10 +16,7 @@ const height = 600;
describe('WebLinksAddon', () => { describe('WebLinksAddon', () => {
before(async function(): Promise<any> { before(async function(): Promise<any> {
const browserType = getBrowserType(); browser = await launchBrowser();
browser = await browserType.launch({
headless: process.argv.includes('--headless')
});
page = await (await browser.newContext()).newPage(); page = await (await browser.newContext()).newPage();
await page.setViewportSize({ width, height }); await page.setViewportSize({ width, height });
}); });
@@ -6,7 +6,7 @@
import { assert } from 'chai'; import { assert } from 'chai';
import { Browser, Page } from 'playwright'; import { Browser, Page } from 'playwright';
import { ITheme } from 'xterm'; import { ITheme } from 'xterm';
import { getBrowserType, openTerminal, pollFor, writeSync } from '../../../out-test/api/TestUtils'; import { getBrowserType, launchBrowser, openTerminal, pollFor, writeSync } from '../../../out-test/api/TestUtils';
import { ITerminalOptions } from '../../../src/common/Types'; import { ITerminalOptions } from '../../../src/common/Types';
const APP = 'http://127.0.0.1:3001/test'; const APP = 'http://127.0.0.1:3001/test';
@@ -905,10 +905,7 @@ async function getCellPixels(col: number, row: number): Promise<number[]> {
} }
async function setupBrowser(options: ITerminalOptions = { rendererType: 'dom' }): Promise<void> { async function setupBrowser(options: ITerminalOptions = { rendererType: 'dom' }): Promise<void> {
const browserType = getBrowserType(); browser = await launchBrowser();
browser = await browserType.launch({
headless: process.argv.includes('--headless')
});
page = await (await browser.newContext()).newPage(); page = await (await browser.newContext()).newPage();
await page.setViewportSize({ width, height }); await page.setViewportSize({ width, height });
await page.goto(APP); await page.goto(APP);
+6
View File
@@ -59,6 +59,12 @@ server.stdout.on('data', (data) => {
`${script}.cmd` : script)); `${script}.cmd` : script));
} }
server.kill();
process.exit(run.status); process.exit(run.status);
} }
}); });
server.stderr.on('data', (data) => {
console.error(data.toString());
});
+2 -5
View File
@@ -3,7 +3,7 @@
* @license MIT * @license MIT
*/ */
import { pollFor, openTerminal, getBrowserType } from './TestUtils'; import { pollFor, openTerminal, launchBrowser } from './TestUtils';
import { Browser, Page } from 'playwright'; import { Browser, Page } from 'playwright';
const APP = 'http://127.0.0.1:3001/test'; const APP = 'http://127.0.0.1:3001/test';
@@ -15,10 +15,7 @@ const height = 600;
describe('CharWidth Integration Tests', function(): void { describe('CharWidth Integration Tests', function(): void {
before(async function(): Promise<any> { before(async function(): Promise<any> {
const browserType = getBrowserType(); browser = await launchBrowser();
browser = await browserType.launch({
headless: process.argv.indexOf('--headless') !== -1
});
page = await (await browser.newContext()).newPage(); page = await (await browser.newContext()).newPage();
await page.setViewportSize({ width, height }); await page.setViewportSize({ width, height });
await page.goto(APP); await page.goto(APP);
+2 -4
View File
@@ -4,7 +4,7 @@
*/ */
import { assert } from 'chai'; import { assert } from 'chai';
import { pollFor, openTerminal, getBrowserType } from './TestUtils'; import { pollFor, openTerminal, getBrowserType, launchBrowser } from './TestUtils';
import { Browser, Page } from 'playwright'; import { Browser, Page } from 'playwright';
import { IRenderDimensions } from 'browser/renderer/Types'; import { IRenderDimensions } from 'browser/renderer/Types';
@@ -21,9 +21,7 @@ describe('InputHandler Integration Tests', function(): void {
before(async function(): Promise<any> { before(async function(): Promise<any> {
const browserType = getBrowserType(); const browserType = getBrowserType();
isChromium = browserType.name() === 'chromium'; isChromium = browserType.name() === 'chromium';
browser = await browserType.launch({ browser = await launchBrowser();
headless: process.argv.indexOf('--headless') !== -1
});
page = await (await browser.newContext()).newPage(); page = await (await browser.newContext()).newPage();
await page.setViewportSize({ width, height }); await page.setViewportSize({ width, height });
await page.goto(APP); await page.goto(APP);
+2 -4
View File
@@ -3,7 +3,7 @@
* @license MIT * @license MIT
*/ */
import { pollFor, writeSync, openTerminal, getBrowserType } from './TestUtils'; import { pollFor, writeSync, openTerminal, getBrowserType, launchBrowser } from './TestUtils';
import { Browser, Page } from 'playwright'; import { Browser, Page } from 'playwright';
const APP = 'http://127.0.0.1:3001/test'; const APP = 'http://127.0.0.1:3001/test';
@@ -211,9 +211,7 @@ describe('Mouse Tracking Tests', async () => {
const itMouse = isChromium ? it : it.skip; const itMouse = isChromium ? it : it.skip;
before(async function(): Promise<void> { before(async function(): Promise<void> {
browser = await browserType.launch({ browser = await launchBrowser();
headless: process.argv.indexOf('--headless') !== -1
});
page = await (await browser.newContext()).newPage(); page = await (await browser.newContext()).newPage();
await page.setViewportSize({ width, height }); await page.setViewportSize({ width, height });
}); });
+2 -5
View File
@@ -4,7 +4,7 @@
*/ */
import { assert } from 'chai'; import { assert } from 'chai';
import { writeSync, openTerminal, getBrowserType } from './TestUtils'; import { writeSync, openTerminal, launchBrowser } from './TestUtils';
import { Browser, Page } from 'playwright'; import { Browser, Page } from 'playwright';
const APP = 'http://127.0.0.1:3001/test'; const APP = 'http://127.0.0.1:3001/test';
@@ -16,10 +16,7 @@ const height = 600;
describe('Parser Integration Tests', function (): void { describe('Parser Integration Tests', function (): void {
before(async function (): Promise<any> { before(async function (): Promise<any> {
const browserType = getBrowserType(); browser = await launchBrowser();
browser = await browserType.launch({
headless: process.argv.indexOf('--headless') !== -1
});
page = await (await browser.newContext()).newPage(); page = await (await browser.newContext()).newPage();
await page.setViewportSize({ width, height }); await page.setViewportSize({ width, height });
await page.goto(APP); await page.goto(APP);
+2 -5
View File
@@ -4,7 +4,7 @@
*/ */
import { assert } from 'chai'; 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'; import { Browser, Page } from 'playwright';
const APP = 'http://127.0.0.1:3001/test'; const APP = 'http://127.0.0.1:3001/test';
@@ -16,10 +16,7 @@ const height = 600;
describe('API Integration Tests', function(): void { describe('API Integration Tests', function(): void {
before(async () => { before(async () => {
const browserType = getBrowserType(); browser = await launchBrowser();
browser = await browserType.launch({
headless: process.argv.indexOf('--headless') !== -1
});
page = await (await browser.newContext()).newPage(); page = await (await browser.newContext()).newPage();
await page.setViewportSize({ width, height }); await page.setViewportSize({ width, height });
}); });
+14
View File
@@ -67,3 +67,17 @@ export function getBrowserType(): playwright.BrowserType<playwright.WebKitBrowse
return browserType; 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);
}