Move to playwright-core, download browser if needed

This commit is contained in:
Daniel Imms
2020-02-15 05:28:21 -08:00
parent 4ebb61b580
commit ffc5e2f446
15 changed files with 50 additions and 40 deletions
+3 -2
View File
@@ -4,7 +4,7 @@
*/
import { pollFor, openTerminal, getBrowserType } from './TestUtils';
import { Browser, Page } from 'playwright';
import { Browser, Page } from 'playwright-core';
const APP = 'http://127.0.0.1:3000/test';
@@ -15,7 +15,8 @@ const height = 600;
describe('CharWidth Integration Tests', function(): void {
before(async function(): Promise<any> {
browser = await getBrowserType().launch({
const browserType = await getBrowserType();
browser = await browserType.launch({
headless: process.argv.indexOf('--headless') !== -1,
args: [`--window-size=${width},${height}`, `--no-sandbox`]
});
+2 -2
View File
@@ -5,7 +5,7 @@
import { assert } from 'chai';
import { pollFor, openTerminal, getBrowserType } from './TestUtils';
import { Browser, Page } from 'playwright';
import { Browser, Page } from 'playwright-core';
import { IRenderDimensions } from 'browser/renderer/Types';
const APP = 'http://127.0.0.1:3000/test';
@@ -19,7 +19,7 @@ let isChromium = false;
describe('InputHandler Integration Tests', function(): void {
before(async function(): Promise<any> {
const browserType = getBrowserType();
const browserType = await getBrowserType();
isChromium = browserType.name() === 'chromium';
browser = await browserType.launch({
headless: process.argv.indexOf('--headless') !== -1,
+8 -5
View File
@@ -4,7 +4,7 @@
*/
import { pollFor, writeSync, openTerminal, getBrowserType } from './TestUtils';
import { Browser, Page } from 'playwright';
import { Browser, Page } from 'playwright-core';
const APP = 'http://127.0.0.1:3000/test';
@@ -22,8 +22,7 @@ const cols = 260;
const rows = 50;
// Wheel events are hacked using private API that is only available in Chromium
const isChromium = getBrowserType().name() === 'chromium';
const itMouse = isChromium ? it : it.skip;
const isChromium = false
// for some reason shift gets not caught by selection manager on macos
const noShift = process.platform === 'darwin' ? false : true;
@@ -208,9 +207,13 @@ function parseReport(encoding: string, msg: number[]): { state: any; row: number
/**
* Mouse tracking tests.
*/
describe('Mouse Tracking Tests', () => {
describe('Mouse Tracking Tests', async () => {
const browserType = await getBrowserType();
browserType.name() === 'chromium';
const itMouse = isChromium ? it : it.skip;
before(async function(): Promise<void> {
browser = await getBrowserType().launch({
browser = await browserType.launch({
headless: process.argv.indexOf('--headless') !== -1,
args: [`--window-size=${width},${height}`, `--no-sandbox`]
});
+3 -2
View File
@@ -5,7 +5,7 @@
import { assert } from 'chai';
import { writeSync, openTerminal, getBrowserType } from './TestUtils';
import { Browser, Page } from 'playwright';
import { Browser, Page } from 'playwright-core';
const APP = 'http://127.0.0.1:3000/test';
@@ -16,7 +16,8 @@ const height = 600;
describe('Parser Integration Tests', function(): void {
before(async function(): Promise<any> {
browser = await getBrowserType().launch({
const browserType = await getBrowserType();
browser = await browserType.launch({
headless: process.argv.indexOf('--headless') !== -1,
args: [`--window-size=${width},${height}`, `--no-sandbox`]
});
+3 -2
View File
@@ -5,7 +5,7 @@
import { assert } from 'chai';
import { pollFor, timeout, writeSync, openTerminal, getBrowserType } from './TestUtils';
import { Browser, Page } from 'playwright';
import { Browser, Page } from 'playwright-core';
const APP = 'http://127.0.0.1:3000/test';
@@ -16,7 +16,8 @@ const height = 600;
describe('API Integration Tests', function(): void {
before(async () => {
browser = await getBrowserType().launch({
const browserType = await getBrowserType();
browser = await browserType.launch({
headless: process.argv.indexOf('--headless') !== -1,
args: [`--window-size=${width},${height}`, `--no-sandbox`]
});
+4 -2
View File
@@ -3,7 +3,7 @@
* @license MIT
*/
import * as playwright from 'playwright';
import * as playwright from 'playwright-core';
import deepEqual = require('deep-equal');
import { ITerminalOptions } from 'xterm';
@@ -41,7 +41,7 @@ export async function openTerminal(page: playwright.Page, options: ITerminalOpti
}
}
export function getBrowserType(): playwright.BrowserType {
export async function getBrowserType(): Promise<playwright.BrowserType> {
// Default to chromium
let browserType: playwright.BrowserType = playwright['chromium'];
@@ -53,5 +53,7 @@ export function getBrowserType(): playwright.BrowserType {
}
}
await browserType.downloadBrowserIfNeeded();
return browserType;
}