Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
chore(test): require playwright fixtures from userland (#3355)
Joel Einbinderd76166beca6f
diff --git a/test/accessibility.spec.js b/test/accessibility.spec.jsindex 82708384b4..858359aa00 100644--- a/test/accessibility.spec.js+++ b/test/accessibility.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const {FFOX, CHROMIUM, WEBKIT} = testOptions;diff --git a/test/autowaiting-basic.spec.ts b/test/autowaiting-basic.spec.tsindex 9ba4755b07..b841c2e43c 100644--- a/test/autowaiting-basic.spec.ts+++ b/test/autowaiting-basic.spec.ts@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+import './base.fixture';import utils from './utils';diff --git a/test/autowaiting-no-hang.spec.ts b/test/autowaiting-no-hang.spec.tsindex db39a32673..a69f1ba839 100644--- a/test/autowaiting-no-hang.spec.ts+++ b/test/autowaiting-no-hang.spec.ts@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+import './base.fixture';import utils from './utils';diff --git a/test/base.fixture.ts b/test/base.fixture.tsnew file mode 100644index 0000000000..b85a1dec35--- /dev/null+++ b/test/base.fixture.ts@@ -0,0 +1,181 @@+/**+ * Copyright Microsoft Corporation. All rights reserved.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import path from 'path';+import fs from 'fs';+import childProcess from 'child_process';+import { LaunchOptions, BrowserType, Browser, BrowserContext, Page, BrowserServer } from '../index';+import { TestServer } from '../utils/testserver/';+import { Connection } from '../lib/rpc/client/connection';+import { Transport } from '../lib/rpc/transport';+import { setUnderTest } from '../lib/helper';+import { installCoverageHooks } from './harness/coverage';+import { valueFromEnv } from './harness/utils';++setUnderTest(); // Note: we must call setUnderTest before requiring Playwright++const browserName = process.env.BROWSER || 'chromium';++declare global {+ interface WorkerState {+ parallelIndex: number;+ http_server: {server: TestServer, httpsServer: TestServer};+ defaultBrowserOptions: LaunchOptions;+ playwright: typeof import('../index');+ browserType: BrowserType<Browser>;+ browser: Browser;+ }+ interface FixtureState {+ toImpl: (rpcObject: any) => any;+ context: BrowserContext;+ server: TestServer;+ page: Page;+ httpsServer: TestServer;+ browserServer: BrowserServer;+ }+}++registerWorkerFixture('parallelIndex', async ({}, test) => {+ await test(parseInt(process.env.JEST_WORKER_ID, 10) - 1);+});++registerWorkerFixture('http_server', async ({parallelIndex}, test) => {+ const assetsPath = path.join(__dirname, 'assets');+ const cachedPath = path.join(__dirname, 'assets', 'cached');++ const port = 8907 + parallelIndex * 2;+ const server = await TestServer.create(assetsPath, port);+ server.enableHTTPCache(cachedPath);++ const httpsPort = port + 1;+ const httpsServer = await TestServer.createHTTPS(assetsPath, httpsPort);+ httpsServer.enableHTTPCache(cachedPath);++ await test({server, httpsServer});++ await Promise.all([+ server.stop(),+ httpsServer.stop(),+ ]);+});++registerWorkerFixture('defaultBrowserOptions', async({}, test) => {+ let executablePath = undefined;+ if (browserName === 'chromium' && process.env.CRPATH)+ executablePath = process.env.CRPATH;+ if (browserName === 'firefox' && process.env.FFPATH)+ executablePath = process.env.FFPATH;+ if (browserName === 'webkit' && process.env.WKPATH)+ executablePath = process.env.WKPATH;+ if (executablePath)+ console.error(`Using executable at ${executablePath}`);+ await test({+ handleSIGINT: false,+ slowMo: valueFromEnv('SLOW_MO', 0),+ headless: !!valueFromEnv('HEADLESS', true),+ executablePath+ });+});++registerWorkerFixture('playwright', async({}, test) => {+ const {coverage, uninstall} = installCoverageHooks(browserName);+ if (process.env.PWCHANNEL === 'wire') {+ const connection = new Connection();+ const spawnedProcess = childProcess.fork(path.join(__dirname, '..', 'lib', 'rpc', 'server'), [], {+ stdio: 'pipe',+ detached: true,+ });+ spawnedProcess.unref();+ const onExit = (exitCode, signal) => {+ throw new Error(`Server closed with exitCode=${exitCode} signal=${signal}`);+ };+ spawnedProcess.on('exit', onExit);+ const transport = new Transport(spawnedProcess.stdin, spawnedProcess.stdout);+ connection.onmessage = message => transport.send(JSON.stringify(message));+ transport.onmessage = message => connection.dispatch(JSON.parse(message));+ const playwrightObject = await connection.waitForObjectWithKnownName('Playwright');+ try {+ await test(playwrightObject);+ } finally {+ spawnedProcess.removeListener('exit', onExit);+ spawnedProcess.stdin.destroy();+ spawnedProcess.stdout.destroy();+ spawnedProcess.stderr.destroy();+ await teardownCoverage();+ }+ } else {+ try {+ await test(require('../index'))+ } finally {+ await teardownCoverage();+ }+ }++ async function teardownCoverage() {+ uninstall();+ const relativeTestPath = path.relative(__dirname, testPath);+ const coveragePath = path.join(path.join(__dirname, 'output-' + browserName), 'coverage', relativeTestPath + '.json');+ const coverageJSON = [...coverage.keys()].filter(key => coverage.get(key));+ await fs.promises.mkdir(path.dirname(coveragePath), { recursive: true });+ await fs.promises.writeFile(coveragePath, JSON.stringify(coverageJSON, undefined, 2), 'utf8');+ }++});++registerFixture('toImpl', async ({playwright}, test) => {+ await test((playwright as any)._toImpl);+});++registerWorkerFixture('browserType', async ({playwright}, test) => {+ await test(playwright[process.env.BROWSER || 'chromium']);+});++registerWorkerFixture('browser', async ({browserType, defaultBrowserOptions}, test) => {+ const browser = await browserType.launch(defaultBrowserOptions);+ try {+ await test(browser);+ if (browser.contexts().length !== 0) {+ console.warn(`\nWARNING: test did not close all created contexts! ${new Error().stack}\n`);+ await Promise.all(browser.contexts().map(context => context.close()));+ }+ } finally {+ await browser.close();+ }+});++registerFixture('context', async ({browser}, test) => {+ const context = await browser.newContext();+ try {+ await test(context);+ } finally {+ await context.close();+ }+});++registerFixture('page', async ({context}, test) => {+ const page = await context.newPage();+ await test(page);+});++registerFixture('server', async ({http_server}, test) => {+ http_server.server.reset();+ await test(http_server.server);+});++registerFixture('httpsServer', async ({http_server}, test) => {+ http_server.httpsServer.reset();+ await test(http_server.httpsServer);+});diff --git a/test/browser.spec.ts b/test/browser.spec.tsindex ffc831919f..07feadfd6a 100644--- a/test/browser.spec.ts+++ b/test/browser.spec.ts@@ -13,6 +13,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+import './base.fixture';import utils from './utils';const {CHROMIUM} = testOptions;diff --git a/test/browsercontext-add-cookies.spec.ts b/test/browsercontext-add-cookies.spec.tsindex 4a3d7cbabb..c48fc6d083 100644--- a/test/browsercontext-add-cookies.spec.ts+++ b/test/browsercontext-add-cookies.spec.ts@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+import './base.fixture';import utils from './utils';const {FFOX, CHROMIUM} = testOptions;diff --git a/test/browsercontext-basic.spec.ts b/test/browsercontext-basic.spec.tsindex 78b45f793b..ad98ee17fd 100644--- a/test/browsercontext-basic.spec.ts+++ b/test/browsercontext-basic.spec.ts@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+import './base.fixture';import utils from './utils';diff --git a/test/browsercontext-clearcookies.spec.ts b/test/browsercontext-clearcookies.spec.tsindex 1f82cfbb47..26f48b9703 100644--- a/test/browsercontext-clearcookies.spec.ts+++ b/test/browsercontext-clearcookies.spec.ts@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+import './base.fixture';import utils from './utils';diff --git a/test/browsercontext-cookies.spec.ts b/test/browsercontext-cookies.spec.tsindex 4da9fdc47d..76f809f34a 100644--- a/test/browsercontext-cookies.spec.ts+++ b/test/browsercontext-cookies.spec.ts@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+import './base.fixture';import utils from './utils';const {FFOX, WEBKIT, WIN} = testOptions;diff --git a/test/browsercontext-credentials.spec.ts b/test/browsercontext-credentials.spec.tsindex ae157fbfd8..43ce9f23eb 100644--- a/test/browsercontext-credentials.spec.ts+++ b/test/browsercontext-credentials.spec.ts@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+import './base.fixture';import utils from './utils';const {CHROMIUM, HEADLESS} = testOptions;diff --git a/test/browsercontext-csp.spec.ts b/test/browsercontext-csp.spec.tsindex b25b848ab6..b47d322017 100644--- a/test/browsercontext-csp.spec.ts+++ b/test/browsercontext-csp.spec.ts@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+import './base.fixture';import * as utils from './utils';diff --git a/test/browsercontext-device.spec.ts b/test/browsercontext-device.spec.tsindex d4b7f9456c..259747d02e 100644--- a/test/browsercontext-device.spec.ts+++ b/test/browsercontext-device.spec.ts@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+import './base.fixture';import utils from './utils';const {FFOX} = testOptions;diff --git a/test/browsercontext-expose-function.spec.ts b/test/browsercontext-expose-function.spec.tsindex d509bb0c9b..373f0858b6 100644--- a/test/browsercontext-expose-function.spec.ts+++ b/test/browsercontext-expose-function.spec.ts@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+import './base.fixture';import utils from './utils';const {FFOX, CHROMIUM, WEBKIT, MAC, CHANNEL, HEADLESS} = testOptions;diff --git a/test/browsercontext-locale.spec.ts b/test/browsercontext-locale.spec.tsindex 4efedcfbe3..cd71605cbc 100644--- a/test/browsercontext-locale.spec.ts+++ b/test/browsercontext-locale.spec.ts@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+import './base.fixture';import utils from './utils';const {CHROMIUM, FFOX, MAC, HEADLESS} = testOptions;diff --git a/test/browsercontext-page-event.spec.ts b/test/browsercontext-page-event.spec.tsindex 012d1474c2..df517cd1f4 100644--- a/test/browsercontext-page-event.spec.ts+++ b/test/browsercontext-page-event.spec.ts@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+import './base.fixture';import utils from './utils';const {FFOX, CHROMIUM, WEBKIT, MAC, CHANNEL, HEADLESS} = testOptions;const {devices} = require('..');diff --git a/test/browsercontext-route.spec.ts b/test/browsercontext-route.spec.tsindex fa6451382e..695b826003 100644--- a/test/browsercontext-route.spec.ts+++ b/test/browsercontext-route.spec.ts@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+import './base.fixture';import utils from './utils';const {FFOX, CHROMIUM, WEBKIT, MAC, CHANNEL, HEADLESS} = testOptions;diff --git a/test/browsercontext-timezone-id.spec.ts b/test/browsercontext-timezone-id.spec.tsindex 3a37fffed1..bc51ada3ec 100644--- a/test/browsercontext-timezone-id.spec.ts+++ b/test/browsercontext-timezone-id.spec.ts@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+import './base.fixture';import utils from './utils';const {CHROMIUM, FFOX, MAC, HEADLESS} = testOptions;diff --git a/test/browsercontext-user-agent.spec.ts b/test/browsercontext-user-agent.spec.tsindex 6891e6a662..f2161ef5d2 100644--- a/test/browsercontext-user-agent.spec.ts+++ b/test/browsercontext-user-agent.spec.ts@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+import './base.fixture';import utils from './utils';const {FFOX, CHROMIUM, WEBKIT, MAC, CHANNEL, HEADLESS} = testOptions;diff --git a/test/browsercontext-viewport-mobile.spec.ts b/test/browsercontext-viewport-mobile.spec.tsindex 328a8b2177..6ea3801ba8 100644--- a/test/browsercontext-viewport-mobile.spec.ts+++ b/test/browsercontext-viewport-mobile.spec.ts@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+import './base.fixture';import utils from './utils';const {CHROMIUM, FFOX, MAC, HEADLESS} = testOptions;diff --git a/test/browsercontext-viewport.spec.ts b/test/browsercontext-viewport.spec.tsindex 3dc0ca6836..dc71f3790a 100644--- a/test/browsercontext-viewport.spec.ts+++ b/test/browsercontext-viewport.spec.ts@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+import './base.fixture';import utils from './utils';const {CHROMIUM, FFOX, MAC, HEADLESS} = testOptions;diff --git a/test/browsertype-basic.spec.ts b/test/browsertype-basic.spec.tsindex d05bc87de3..1d727ae3bf 100644--- a/test/browsertype-basic.spec.ts+++ b/test/browsertype-basic.spec.ts@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+import './base.fixture';import path from 'path';import fs from 'fs';diff --git a/test/browsertype-connect.spec.ts b/test/browsertype-connect.spec.tsindex 0d6cb2057c..8b3c33c409 100644--- a/test/browsertype-connect.spec.ts+++ b/test/browsertype-connect.spec.ts@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+import './base.fixture';import utils from './utils';const {FFOX, CHROMIUM, WEBKIT, WIN, USES_HOOKS, CHANNEL} = testOptions;diff --git a/test/browsertype-launch-server.spec.js b/test/browsertype-launch-server.spec.jsindex 4f6b0fde46..067c8a1202 100644--- a/test/browsertype-launch-server.spec.js+++ b/test/browsertype-launch-server.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const path = require('path');const fs = require('fs');diff --git a/test/browsertype-launch.spec.ts b/test/browsertype-launch.spec.tsindex 3da77183e3..504226dce9 100644--- a/test/browsertype-launch.spec.ts+++ b/test/browsertype-launch.spec.ts@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+import './base.fixture';import path from 'path';import fs from 'fs';diff --git a/test/capabilities.spec.ts b/test/capabilities.spec.tsindex adcb908ca1..dad1f11946 100644--- a/test/capabilities.spec.ts+++ b/test/capabilities.spec.ts@@ -13,6 +13,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+import './base.fixture';import path from 'path';import url from 'url';diff --git a/test/channels.spec.ts b/test/channels.spec.tsindex a92d00c0f7..e3607786ae 100644--- a/test/channels.spec.ts+++ b/test/channels.spec.ts@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+import './base.fixture';import utils from './utils';import { ChromiumBrowser } from '../types/types';diff --git a/test/check.spec.ts b/test/check.spec.tsindex e3059ae651..db987757f5 100644--- a/test/check.spec.ts+++ b/test/check.spec.ts@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+import './base.fixture';it('should check the box', async({page}) => {await page.setContent(`<input id='checkbox' type='checkbox'></input>`);diff --git a/test/chromium-css-coverage.spec.ts b/test/chromium-css-coverage.spec.tsindex fac6c3ce42..bc9e7462db 100644--- a/test/chromium-css-coverage.spec.ts+++ b/test/chromium-css-coverage.spec.ts@@ -13,6 +13,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+import './base.fixture';import utils from './utils';const {FFOX, CHROMIUM, WEBKIT} = testOptions;diff --git a/test/chromium-js-coverage.spec.ts b/test/chromium-js-coverage.spec.tsindex 26fe36c768..cfc34f5edc 100644--- a/test/chromium-js-coverage.spec.ts+++ b/test/chromium-js-coverage.spec.ts@@ -13,6 +13,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+import './base.fixture';import utils from './utils';const {FFOX, CHROMIUM, WEBKIT} = testOptions;diff --git a/test/chromium/chromium.spec.js b/test/chromium/chromium.spec.jsindex 7aa6998ed9..ce796bd004 100644--- a/test/chromium/chromium.spec.js+++ b/test/chromium/chromium.spec.js@@ -13,6 +13,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('../base.fixture');const {FFOX, CHROMIUM, WEBKIT, CHANNEL} = testOptions;diff --git a/test/chromium/launcher.spec.js b/test/chromium/launcher.spec.jsindex 19f64cb8c3..d24c069429 100644--- a/test/chromium/launcher.spec.js+++ b/test/chromium/launcher.spec.js@@ -13,6 +13,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('../base.fixture');const path = require('path');const utils = require('../utils');diff --git a/test/chromium/oopif.spec.ts b/test/chromium/oopif.spec.tsindex 0df33e73a3..d8beeca36f 100644--- a/test/chromium/oopif.spec.ts+++ b/test/chromium/oopif.spec.ts@@ -13,6 +13,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+import '../base.fixture';import { Page, Browser, BrowserContext } from '../../types/types';const {FFOX, CHROMIUM, WEBKIT, CHANNEL} = testOptions;diff --git a/test/chromium/session.spec.js b/test/chromium/session.spec.jsindex 60558021b9..4d0dfd5279 100644--- a/test/chromium/session.spec.js+++ b/test/chromium/session.spec.js@@ -13,6 +13,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('../base.fixture');const {FFOX, CHROMIUM, WEBKIT, CHANNEL, USES_HOOKS} = testOptions;diff --git a/test/chromium/tracing.spec.ts b/test/chromium/tracing.spec.tsindex 2346299003..070447f5a1 100644--- a/test/chromium/tracing.spec.ts+++ b/test/chromium/tracing.spec.ts@@ -13,6 +13,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+import '../base.fixture';import fs from 'fs';import path from 'path';diff --git a/test/click-react.spec.ts b/test/click-react.spec.tsindex ec51d3e4d0..b08bd55fb7 100644--- a/test/click-react.spec.ts+++ b/test/click-react.spec.ts@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+import './base.fixture';import utils from './utils';declare const renderComponent;diff --git a/test/click-timeout-1.spec.ts b/test/click-timeout-1.spec.tsindex ac2634a555..c20dddeca7 100644--- a/test/click-timeout-1.spec.ts+++ b/test/click-timeout-1.spec.ts@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+import './base.fixture';import utils from './utils';const {USES_HOOKS} = testOptions;diff --git a/test/click-timeout-2.spec.ts b/test/click-timeout-2.spec.tsindex 857acec095..eb4b606627 100644--- a/test/click-timeout-2.spec.ts+++ b/test/click-timeout-2.spec.ts@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+import './base.fixture';import utils from './utils';const {USES_HOOKS} = testOptions;diff --git a/test/click-timeout-3.spec.ts b/test/click-timeout-3.spec.tsindex d8636f4487..b8a1dddf1d 100644--- a/test/click-timeout-3.spec.ts+++ b/test/click-timeout-3.spec.ts@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+import './base.fixture';import utils from './utils';const {USES_HOOKS} = testOptions;diff --git a/test/click-timeout-4.spec.ts b/test/click-timeout-4.spec.tsindex 7ce06aab6e..37e8ea9b1f 100644--- a/test/click-timeout-4.spec.ts+++ b/test/click-timeout-4.spec.ts@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+import './base.fixture';import utils from './utils';it('should timeout waiting for stable position', async({page, server}) => {diff --git a/test/click.spec.ts b/test/click.spec.tsindex a4a4b4c886..55eed58504 100644--- a/test/click.spec.ts+++ b/test/click.spec.ts@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+import './base.fixture';import utils from './utils';const {FFOX, CHROMIUM, WEBKIT, HEADLESS, USES_HOOKS} = testOptions;diff --git a/test/defaultbrowsercontext.spec.ts b/test/defaultbrowsercontext.spec.tsindex 865423265b..d4dae50bbd 100644--- a/test/defaultbrowsercontext.spec.ts+++ b/test/defaultbrowsercontext.spec.ts@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+import './base.fixture';import fs from 'fs';import path from 'path';diff --git a/test/dialog.spec.js b/test/dialog.spec.jsindex 7fcc498feb..6165530c9b 100644--- a/test/dialog.spec.js+++ b/test/dialog.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const {FFOX, CHROMIUM, WEBKIT, CHANNEL} = testOptions;diff --git a/test/dispatchevent.spec.js b/test/dispatchevent.spec.jsindex 33753b0361..68840b8286 100644--- a/test/dispatchevent.spec.js+++ b/test/dispatchevent.spec.js@@ -13,6 +13,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const utils = require('./utils');const {FFOX, CHROMIUM, WEBKIT, WIN, USES_HOOKS} = testOptions;diff --git a/test/download.spec.ts b/test/download.spec.tsindex 88d433725e..b1f2c9bf0b 100644--- a/test/download.spec.ts+++ b/test/download.spec.ts@@ -13,6 +13,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+import './base.fixture';import fs from 'fs';import path from 'path';diff --git a/test/downloads-path.spec.ts b/test/downloads-path.spec.tsindex 74c7ccf0c8..cf9f8b1d5e 100644--- a/test/downloads-path.spec.ts+++ b/test/downloads-path.spec.ts@@ -13,6 +13,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+import './base.fixture';import path from 'path';import fs from 'fs';diff --git a/test/electron/electron-app.spec.js b/test/electron/electron-app.spec.jsindex 54dcf7384a..e255e4e588 100644--- a/test/electron/electron-app.spec.js+++ b/test/electron/electron-app.spec.js@@ -13,6 +13,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('../base.fixture');const path = require('path');const electronName = process.platform === 'win32' ? 'electron.cmd' : 'electron';diff --git a/test/electron/electron-window.spec.js b/test/electron/electron-window.spec.jsindex 9e80301cc2..c683921504 100644--- a/test/electron/electron-window.spec.js+++ b/test/electron/electron-window.spec.js@@ -13,6 +13,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('../base.fixture');const path = require('path');const electronName = process.platform === 'win32' ? 'electron.cmd' : 'electron';diff --git a/test/elementhandle-bounding-box.spec.js b/test/elementhandle-bounding-box.spec.jsindex 7e0840a076..e71b7c1e78 100644--- a/test/elementhandle-bounding-box.spec.js+++ b/test/elementhandle-bounding-box.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const utils = require('./utils');const { FFOX, HEADLESS } = testOptions;diff --git a/test/elementhandle-click.spec.js b/test/elementhandle-click.spec.jsindex 11cbe8401b..eb854a6e90 100644--- a/test/elementhandle-click.spec.js+++ b/test/elementhandle-click.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const utils = require('./utils');const { FFOX, HEADLESS } = testOptions;diff --git a/test/elementhandle-content-frame.spec.js b/test/elementhandle-content-frame.spec.jsindex c0a35f0f3a..9ad8f1096d 100644--- a/test/elementhandle-content-frame.spec.js+++ b/test/elementhandle-content-frame.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const utils = require('./utils');const { FFOX, HEADLESS } = testOptions;diff --git a/test/elementhandle-convenience.spec.js b/test/elementhandle-convenience.spec.jsindex d9d8b8d2d7..091a651123 100644--- a/test/elementhandle-convenience.spec.js+++ b/test/elementhandle-convenience.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const utils = require('./utils');const { FFOX, HEADLESS } = testOptions;diff --git a/test/elementhandle-eval-on-selector.spec.js b/test/elementhandle-eval-on-selector.spec.jsindex 283bc05ba1..4884548502 100644--- a/test/elementhandle-eval-on-selector.spec.js+++ b/test/elementhandle-eval-on-selector.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const path = require('path');const utils = require('./utils');diff --git a/test/elementhandle-misc.spec.js b/test/elementhandle-misc.spec.jsindex e6486a82a8..3bdb607ced 100644--- a/test/elementhandle-misc.spec.js+++ b/test/elementhandle-misc.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const utils = require('./utils');const { FFOX, HEADLESS } = testOptions;diff --git a/test/elementhandle-owner-frame.spec.js b/test/elementhandle-owner-frame.spec.jsindex 4e7ed651a3..101e3a9d48 100644--- a/test/elementhandle-owner-frame.spec.js+++ b/test/elementhandle-owner-frame.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const utils = require('./utils');const { FFOX, HEADLESS } = testOptions;diff --git a/test/elementhandle-press.spec.js b/test/elementhandle-press.spec.jsindex 96d6096234..184e8d001c 100644--- a/test/elementhandle-press.spec.js+++ b/test/elementhandle-press.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const utils = require('./utils');const { FFOX, HEADLESS } = testOptions;diff --git a/test/elementhandle-query-selector.spec.js b/test/elementhandle-query-selector.spec.jsindex f1b19c0b10..55686fb364 100644--- a/test/elementhandle-query-selector.spec.js+++ b/test/elementhandle-query-selector.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const path = require('path');const utils = require('./utils');diff --git a/test/elementhandle-screenshot.spec.js b/test/elementhandle-screenshot.spec.jsindex ff3a443d78..67b36971ca 100644--- a/test/elementhandle-screenshot.spec.js+++ b/test/elementhandle-screenshot.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const utils = require('./utils');const {FFOX, CHROMIUM, WEBKIT, USES_HOOKS, HEADLESS} = testOptions;diff --git a/test/elementhandle-scroll-into-view.spec.js b/test/elementhandle-scroll-into-view.spec.jsindex 0d625fa15c..c7aa663909 100644--- a/test/elementhandle-scroll-into-view.spec.js+++ b/test/elementhandle-scroll-into-view.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const utils = require('./utils');const { FFOX, HEADLESS } = testOptions;diff --git a/test/elementhandle-select-text.spec.js b/test/elementhandle-select-text.spec.jsindex 60a1af9094..ca3e8a7d34 100644--- a/test/elementhandle-select-text.spec.js+++ b/test/elementhandle-select-text.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const utils = require('./utils');const { FFOX, HEADLESS } = testOptions;diff --git a/test/elementhandle-type.spec.js b/test/elementhandle-type.spec.jsindex 5b693d5bfb..bb93914516 100644--- a/test/elementhandle-type.spec.js+++ b/test/elementhandle-type.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const utils = require('./utils');const { FFOX, HEADLESS } = testOptions;diff --git a/test/emulation-focus.spec.js b/test/emulation-focus.spec.jsindex ac0e22adb9..d7cd816a7d 100644--- a/test/emulation-focus.spec.js+++ b/test/emulation-focus.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const utils = require('./utils');const {CHROMIUM, FFOX, MAC, HEADLESS} = testOptions;diff --git a/test/eval-on-selector-all.spec.js b/test/eval-on-selector-all.spec.jsindex c16005569f..48a62db0f8 100644--- a/test/eval-on-selector-all.spec.js+++ b/test/eval-on-selector-all.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const path = require('path');const utils = require('./utils');diff --git a/test/eval-on-selector.spec.js b/test/eval-on-selector.spec.jsindex 96a9b16f90..6e91381c09 100644--- a/test/eval-on-selector.spec.js+++ b/test/eval-on-selector.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const path = require('path');const utils = require('./utils');diff --git a/test/firefox/launcher.spec.js b/test/firefox/launcher.spec.jsindex 2ed95e6522..73c3487dbe 100644--- a/test/firefox/launcher.spec.js+++ b/test/firefox/launcher.spec.js@@ -13,6 +13,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('../base.fixture');const { FFOX } = testOptions;diff --git a/test/fixtures.spec.ts b/test/fixtures.spec.tsindex b29fcb0ab2..8ceea67000 100644--- a/test/fixtures.spec.ts+++ b/test/fixtures.spec.ts@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+import './base.fixture';import path from 'path';import {spawn, execSync} from 'child_process';diff --git a/test/focus.spec.js b/test/focus.spec.jsindex a4dcf80068..910d359f41 100644--- a/test/focus.spec.js+++ b/test/focus.spec.js@@ -13,6 +13,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const {FFOX, CHROMIUM, LINUX, WEBKIT, MAC} = testOptions;diff --git a/test/frame-evaluate.spec.js b/test/frame-evaluate.spec.jsindex a6fc6a1022..c2e890d60b 100644--- a/test/frame-evaluate.spec.js+++ b/test/frame-evaluate.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const utils = require('./utils');const path = require('path');diff --git a/test/frame-frame-element.spec.js b/test/frame-frame-element.spec.jsindex bca18af9f6..ff687b41a3 100644--- a/test/frame-frame-element.spec.js+++ b/test/frame-frame-element.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const utils = require('./utils');const {FFOX, CHROMIUM, WEBKIT} = testOptions;diff --git a/test/frame-goto.spec.js b/test/frame-goto.spec.jsindex dbd01b2d14..930396ba89 100644--- a/test/frame-goto.spec.js+++ b/test/frame-goto.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const utils = require('./utils');const path = require('path');diff --git a/test/frame-hierarcy.spec.js b/test/frame-hierarcy.spec.jsindex f302c62fb9..de87206e69 100644--- a/test/frame-hierarcy.spec.js+++ b/test/frame-hierarcy.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const utils = require('./utils');const {FFOX, CHROMIUM, WEBKIT} = testOptions;diff --git a/test/geolocation.spec.js b/test/geolocation.spec.jsindex 7559caa8bc..1a8dfa9cea 100644--- a/test/geolocation.spec.js+++ b/test/geolocation.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const {FFOX, CHROMIUM, WEBKIT} = testOptions;diff --git a/test/jest/coverage.js b/test/harness/coverage.jssimilarity index 99%rename from test/jest/coverage.jsrename to test/harness/coverage.jsindex 14a176a7be..f59792deed 100644--- a/test/jest/coverage.js+++ b/test/harness/coverage.js@@ -24,6 +24,7 @@function traceAPICoverage(apiCoverage, api, events) {const uninstalls = [];for (const [name, classType] of Object.entries(api)) {+ // console.log('trace', name);const className = name.substring(0, 1).toLowerCase() + name.substring(1);for (const methodName of Reflect.ownKeys(classType.prototype)) {const method = Reflect.get(classType.prototype, methodName);diff --git a/test/headful.spec.js b/test/headful.spec.jsindex 9b0ffb7f90..046357b54a 100644--- a/test/headful.spec.js+++ b/test/headful.spec.js@@ -13,6 +13,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const utils = require('./utils');const { makeUserDataDir, removeUserDataDir } = utils;diff --git a/test/ignorehttpserrors.spec.js b/test/ignorehttpserrors.spec.jsindex e875d43dac..27df266bb7 100644--- a/test/ignorehttpserrors.spec.js+++ b/test/ignorehttpserrors.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const {FFOX, CHROMIUM, WEBKIT, MAC} = testOptions;diff --git a/test/interception.spec.js b/test/interception.spec.jsindex 0cf6134fde..ef5db79fba 100644--- a/test/interception.spec.js+++ b/test/interception.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const fs = require('fs');const path = require('path');diff --git a/test/jest/checkCoverage.js b/test/jest/checkCoverage.jsindex 6cda377299..19562a2fdf 100644--- a/test/jest/checkCoverage.js+++ b/test/jest/checkCoverage.js@@ -15,7 +15,7 @@*/const path = require('path');const fs = require('fs');-const {installCoverageHooks} = require('./coverage');+const {installCoverageHooks} = require('../harness/coverage');const browserName = process.env.BROWSER || 'chromium';diff --git a/test/jest/playwrightEnvironment.js b/test/jest/playwrightEnvironment.jsindex e76a4c8098..56efc314d8 100644--- a/test/jest/playwrightEnvironment.js+++ b/test/jest/playwrightEnvironment.js@@ -15,22 +15,19 @@*/const { FixturePool, registerFixture, registerWorkerFixture } = require('../harness/fixturePool');-const registerFixtures = require('../harness/fixtures');const os = require('os');const path = require('path');const fs = require('fs');const debug = require('debug');const util = require('util');const GoldenUtils = require('../../utils/testrunner/GoldenUtils');-const {installCoverageHooks} = require('./coverage');const reportOnly = !!process.env.REPORT_ONLY_PLATFORM;const { ModuleMocker } = require('jest-mock');global.testOptions = require('../harness/testOptions');global.registerFixture = registerFixture;global.registerWorkerFixture = registerWorkerFixture;--registerFixtures(global);+global.testPath = null;const browserName = process.env.BROWSER || 'chromium';@@ -53,32 +50,16 @@ class PlaywrightEnvironment {this.fixturePool = new FixturePool();this.global = global;this.global.testOptions = testOptions;- this.testPath = context.testPath;+ this.global.testPath = context.testPath;}async setup() {- const {coverage, uninstall} = installCoverageHooks(browserName);- this.coverage = coverage;- this.uninstallCoverage = uninstall;currentFixturePool = this.fixturePool;}async teardown() {currentFixturePool = null;await this.fixturePool.teardownScope('worker');- // If the setup throws an error, we don't want to override it- // with a useless error about this.coverage not existing.- if (!this.coverage)- return;- this.uninstallCoverage();- const testRoot = path.join(__dirname, '..');- const relativeTestPath = path.relative(testRoot, this.testPath);- const coveragePath = path.join(outputPath, 'coverage', relativeTestPath + '.json');- const coverageJSON = [...this.coverage.keys()].filter(key => this.coverage.get(key));- await fs.promises.mkdir(path.dirname(coveragePath), { recursive: true });- await fs.promises.writeFile(coveragePath, JSON.stringify(coverageJSON, undefined, 2), 'utf8');- delete this.coverage;- delete this.uninstallCoverage;}runScript(script) {diff --git a/test/jshandle-as-element.spec.js b/test/jshandle-as-element.spec.jsindex 5ec08ccd2c..e904d99a2b 100644--- a/test/jshandle-as-element.spec.js+++ b/test/jshandle-as-element.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const {FFOX, CHROMIUM, WEBKIT} = testOptions;diff --git a/test/jshandle-evaluate.spec.js b/test/jshandle-evaluate.spec.jsindex 7c060ec78c..b26bf7ccc8 100644--- a/test/jshandle-evaluate.spec.js+++ b/test/jshandle-evaluate.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const {FFOX, CHROMIUM, WEBKIT} = testOptions;diff --git a/test/jshandle-json-value.spec.js b/test/jshandle-json-value.spec.jsindex 8c43d462b3..73529b8678 100644--- a/test/jshandle-json-value.spec.js+++ b/test/jshandle-json-value.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const {FFOX, CHROMIUM, WEBKIT} = testOptions;diff --git a/test/jshandle-properties.spec.js b/test/jshandle-properties.spec.jsindex e5efb285c0..90328cfc66 100644--- a/test/jshandle-properties.spec.js+++ b/test/jshandle-properties.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const {FFOX, CHROMIUM, WEBKIT} = testOptions;diff --git a/test/jshandle-to-string.spec.js b/test/jshandle-to-string.spec.jsindex 0f42cbc06f..84834de2b7 100644--- a/test/jshandle-to-string.spec.js+++ b/test/jshandle-to-string.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const {FFOX, CHROMIUM, WEBKIT} = testOptions;diff --git a/test/keyboard.spec.js b/test/keyboard.spec.jsindex f315f06d71..2b7728c0a6 100644--- a/test/keyboard.spec.js+++ b/test/keyboard.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const utils = require('./utils');diff --git a/test/launcher.spec.js b/test/launcher.spec.jsindex cb742c3936..f6f52f0821 100644--- a/test/launcher.spec.js+++ b/test/launcher.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const path = require('path');const fs = require('fs');diff --git a/test/logger.spec.js b/test/logger.spec.jsindex 0cc55dd724..724fa7c85c 100644--- a/test/logger.spec.js+++ b/test/logger.spec.js@@ -13,6 +13,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const fs = require('fs');const path = require('path');diff --git a/test/mouse.spec.js b/test/mouse.spec.jsindex cb3325d04e..d29c3a3551 100644--- a/test/mouse.spec.js+++ b/test/mouse.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const {FFOX, CHROMIUM, WEBKIT, MAC, WIN} = testOptions;diff --git a/test/multiclient.spec.js b/test/multiclient.spec.jsindex 1f378527d8..05044b17ec 100644--- a/test/multiclient.spec.js+++ b/test/multiclient.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const {FFOX, CHROMIUM, WEBKIT} = testOptions;diff --git a/test/navigation.spec.js b/test/navigation.spec.jsindex 63461aa9f0..46f6f4585f 100644--- a/test/navigation.spec.js+++ b/test/navigation.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');it('should work with _blank target', async({page, server}) => {server.setRoute('/empty.html', (req, res) => {diff --git a/test/network-request.spec.js b/test/network-request.spec.jsindex be28a030f8..3110c5c4ed 100644--- a/test/network-request.spec.js+++ b/test/network-request.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const fs = require('fs');const path = require('path');diff --git a/test/network-response.spec.js b/test/network-response.spec.jsindex 4286ee5ba5..a6c8ce9b3d 100644--- a/test/network-response.spec.js+++ b/test/network-response.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const fs = require('fs');const path = require('path');diff --git a/test/nojest/nojest.js b/test/nojest/nojest.jsindex 8ec58f20a8..d0d843943d 100644--- a/test/nojest/nojest.js+++ b/test/nojest/nojest.js@@ -22,14 +22,12 @@ const pirates = require('pirates');const babel = require('@babel/core');const TestRunner = require('../../utils/testrunner');const { FixturePool, registerFixture, registerWorkerFixture } = require('../harness/fixturePool');-const registerFixtures = require('../harness/fixtures');const testOptions = require('../harness/testOptions');Error.stackTraceLimit = 15;global.testOptions = require('../harness/testOptions');global.registerFixture = registerFixture;global.registerWorkerFixture = registerWorkerFixture;-registerFixtures(global);process.env.JEST_WORKER_ID = 1;const browserName = process.env.BROWSER || 'chromium';const goldenPath = path.join(__dirname, '..', 'golden-' + browserName);diff --git a/test/page-add-init-script.spec.js b/test/page-add-init-script.spec.jsindex 3694cd53c6..8be88d117d 100644--- a/test/page-add-init-script.spec.js+++ b/test/page-add-init-script.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const utils = require('./utils');const path = require('path');diff --git a/test/page-add-script-tag.spec.js b/test/page-add-script-tag.spec.jsindex e19311d106..362b6ea110 100644--- a/test/page-add-script-tag.spec.js+++ b/test/page-add-script-tag.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const path = require('path');const util = require('util');diff --git a/test/page-add-style-tag.spec.js b/test/page-add-style-tag.spec.jsindex df29e2e914..457b076350 100644--- a/test/page-add-style-tag.spec.js+++ b/test/page-add-style-tag.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const path = require('path');const util = require('util');diff --git a/test/page-basic.spec.js b/test/page-basic.spec.jsindex 801c9f93be..f96696246b 100644--- a/test/page-basic.spec.js+++ b/test/page-basic.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const path = require('path');const util = require('util');diff --git a/test/page-emulate-media.spec.js b/test/page-emulate-media.spec.jsindex 9ba13fed81..ec0cfd4cc2 100644--- a/test/page-emulate-media.spec.js+++ b/test/page-emulate-media.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const utils = require('./utils');const {CHROMIUM, FFOX, MAC, HEADLESS} = testOptions;diff --git a/test/page-evaluate-handle.spec.js b/test/page-evaluate-handle.spec.jsindex 3a35fa8665..7b9062f2af 100644--- a/test/page-evaluate-handle.spec.js+++ b/test/page-evaluate-handle.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const {FFOX, CHROMIUM, WEBKIT} = testOptions;diff --git a/test/page-evaluate.spec.js b/test/page-evaluate.spec.jsindex d23411e041..ea63280f72 100644--- a/test/page-evaluate.spec.js+++ b/test/page-evaluate.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const utils = require('./utils');const path = require('path');diff --git a/test/page-event-console.spec.js b/test/page-event-console.spec.jsindex 81222fb04d..474e86b725 100644--- a/test/page-event-console.spec.js+++ b/test/page-event-console.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const path = require('path');const util = require('util');diff --git a/test/page-event-crash.spec.js b/test/page-event-crash.spec.jsindex 0ce6699779..02c6239082 100644--- a/test/page-event-crash.spec.js+++ b/test/page-event-crash.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const path = require('path');const util = require('util');diff --git a/test/page-event-network.spec.js b/test/page-event-network.spec.jsindex 920689c7ab..8638c923de 100644--- a/test/page-event-network.spec.js+++ b/test/page-event-network.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const fs = require('fs');const path = require('path');diff --git a/test/page-event-pageerror.spec.js b/test/page-event-pageerror.spec.jsindex b0694d1270..d5cb1aa6da 100644--- a/test/page-event-pageerror.spec.js+++ b/test/page-event-pageerror.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const path = require('path');const {FFOX, CHROMIUM, WEBKIT, WIN, USES_HOOKS, CHANNEL} = testOptions;diff --git a/test/page-event-popup.spec.js b/test/page-event-popup.spec.jsindex e5de6d81d1..584c1ca908 100644--- a/test/page-event-popup.spec.js+++ b/test/page-event-popup.spec.js@@ -13,6 +13,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const {FFOX, CHROMIUM, WEBKIT, MAC} = testOptions;diff --git a/test/page-event-request.spec.js b/test/page-event-request.spec.jsindex 3d3252a728..9391509344 100644--- a/test/page-event-request.spec.js+++ b/test/page-event-request.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const fs = require('fs');const path = require('path');diff --git a/test/page-expose-function.spec.js b/test/page-expose-function.spec.jsindex 258665c46d..94135c3aff 100644--- a/test/page-expose-function.spec.js+++ b/test/page-expose-function.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const path = require('path');const util = require('util');diff --git a/test/page-fill.spec.js b/test/page-fill.spec.jsindex 5158bd4863..ab9c390ce1 100644--- a/test/page-fill.spec.js+++ b/test/page-fill.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const path = require('path');const util = require('util');diff --git a/test/page-goto.spec.js b/test/page-goto.spec.jsindex 53ff33bd33..68e059e5c9 100644--- a/test/page-goto.spec.js+++ b/test/page-goto.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const utils = require('./utils');const path = require('path');diff --git a/test/page-history.spec.js b/test/page-history.spec.jsindex b6306fffdc..d115bc0ff7 100644--- a/test/page-history.spec.js+++ b/test/page-history.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const path = require('path');const url = require('url');diff --git a/test/page-network-idle.spec.js b/test/page-network-idle.spec.jsindex 4209888c07..71c06b19c3 100644--- a/test/page-network-idle.spec.js+++ b/test/page-network-idle.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const utils = require('./utils');const path = require('path');diff --git a/test/page-route.spec.js b/test/page-route.spec.jsindex 7711612e4d..c410c86e6b 100644--- a/test/page-route.spec.js+++ b/test/page-route.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const fs = require('fs');const path = require('path');diff --git a/test/page-screenshot.spec.js b/test/page-screenshot.spec.jsindex ed6805059a..e01247bf78 100644--- a/test/page-screenshot.spec.js+++ b/test/page-screenshot.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const utils = require('./utils');const {FFOX, CHROMIUM, WEBKIT, USES_HOOKS, HEADLESS} = testOptions;diff --git a/test/page-select-option.spec.js b/test/page-select-option.spec.jsindex 7d2eab8d95..ed4a3c3233 100644--- a/test/page-select-option.spec.js+++ b/test/page-select-option.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const path = require('path');const util = require('util');diff --git a/test/page-set-content.spec.js b/test/page-set-content.spec.jsindex 88fa37e1b1..a80e08b370 100644--- a/test/page-set-content.spec.js+++ b/test/page-set-content.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const path = require('path');const util = require('util');diff --git a/test/page-set-extra-http-headers.spec.js b/test/page-set-extra-http-headers.spec.jsindex dc1f0f0602..5d98b33c4e 100644--- a/test/page-set-extra-http-headers.spec.js+++ b/test/page-set-extra-http-headers.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const fs = require('fs');const path = require('path');diff --git a/test/page-set-input-files.spec.js b/test/page-set-input-files.spec.jsindex 5948b649c2..c1e8eb6b8e 100644--- a/test/page-set-input-files.spec.js+++ b/test/page-set-input-files.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const path = require('path');const fs = require('fs');diff --git a/test/page-wait-for-load-state.spec.js b/test/page-wait-for-load-state.spec.jsindex 37b87c68c0..9e05a42c6b 100644--- a/test/page-wait-for-load-state.spec.js+++ b/test/page-wait-for-load-state.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const utils = require('./utils');const path = require('path');diff --git a/test/page-wait-for-navigation.spec.js b/test/page-wait-for-navigation.spec.jsindex e53d97a175..49ccd1b80c 100644--- a/test/page-wait-for-navigation.spec.js+++ b/test/page-wait-for-navigation.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const utils = require('./utils');const path = require('path');diff --git a/test/page-wait-for-request.spec.js b/test/page-wait-for-request.spec.jsindex df8f2088d8..59cd49a914 100644--- a/test/page-wait-for-request.spec.js+++ b/test/page-wait-for-request.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const path = require('path');const util = require('util');diff --git a/test/page-wait-for-response.spec.js b/test/page-wait-for-response.spec.jsindex d00adf4ce3..c3ece05d50 100644--- a/test/page-wait-for-response.spec.js+++ b/test/page-wait-for-response.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const path = require('path');const util = require('util');diff --git a/test/pdf.spec.ts b/test/pdf.spec.tsindex 27fe54c3ff..0c74c549fc 100644--- a/test/pdf.spec.ts+++ b/test/pdf.spec.ts@@ -13,6 +13,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+import './base.fixture';import fs from 'fs'import path from 'path'diff --git a/test/permissions.spec.js b/test/permissions.spec.jsindex 501adf127f..31d1e5c432 100644--- a/test/permissions.spec.js+++ b/test/permissions.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const {FFOX, CHROMIUM, WEBKIT, LINUX, HEADLESS} = testOptions;diff --git a/test/popup.spec.js b/test/popup.spec.jsindex 90ee69b8ff..bd1f624fc7 100644--- a/test/popup.spec.js+++ b/test/popup.spec.js@@ -13,6 +13,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const {FFOX, CHROMIUM, WEBKIT, MAC} = testOptions;diff --git a/test/proxy.spec.js b/test/proxy.spec.jsindex 667bdd16b1..12582a41ea 100644--- a/test/proxy.spec.js+++ b/test/proxy.spec.js@@ -13,6 +13,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const socks = require('socksv5');const utils = require('./utils');diff --git a/test/queryselector.spec.js b/test/queryselector.spec.jsindex 8d872f269b..1cc2f5bdde 100644--- a/test/queryselector.spec.js+++ b/test/queryselector.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const path = require('path');const utils = require('./utils');diff --git a/test/request-continue.spec.js b/test/request-continue.spec.jsindex 787a718f0e..f7b1335758 100644--- a/test/request-continue.spec.js+++ b/test/request-continue.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const fs = require('fs');const path = require('path');diff --git a/test/request-fulfill.spec.js b/test/request-fulfill.spec.jsindex b8d765c213..80c5feda17 100644--- a/test/request-fulfill.spec.js+++ b/test/request-fulfill.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const fs = require('fs');const path = require('path');diff --git a/test/selectors-css.spec.js b/test/selectors-css.spec.jsindex 9533a9289d..77caefa15b 100644--- a/test/selectors-css.spec.js+++ b/test/selectors-css.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const path = require('path');const utils = require('./utils');diff --git a/test/selectors-misc.spec.js b/test/selectors-misc.spec.jsindex bf0e492fdd..6277020d9a 100644--- a/test/selectors-misc.spec.js+++ b/test/selectors-misc.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const path = require('path');const utils = require('./utils');diff --git a/test/selectors-register.spec.js b/test/selectors-register.spec.jsindex ff1151096c..faa7d1402d 100644--- a/test/selectors-register.spec.js+++ b/test/selectors-register.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const path = require('path');const utils = require('./utils');diff --git a/test/selectors-text.spec.js b/test/selectors-text.spec.jsindex bef71cf63b..6ebc2af43d 100644--- a/test/selectors-text.spec.js+++ b/test/selectors-text.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const path = require('path');const utils = require('./utils');diff --git a/test/tsconfig.json b/test/tsconfig.jsonindex 6ed2fc42d8..3267edb3c7 100644--- a/test/tsconfig.json+++ b/test/tsconfig.json@@ -8,5 +8,5 @@"strictNullChecks": false,"allowSyntheticDefaultImports": true,},- "include": ["**/*.spec.js", "types.d.ts", "**/*.spec.ts"]+ "include": ["**/*.spec.js", "types.d.ts", "**/*.ts"]}\ No newline at end of filediff --git a/test/types.d.ts b/test/types.d.tsindex aad38b51d4..713029948c 100644--- a/test/types.d.ts+++ b/test/types.d.ts@@ -10,38 +10,12 @@ type ItFunction<STATE> = ((name: string, inner: (state: STATE) => Promise<void>)repeat(n: number): ItFunction<STATE>;};-interface FixtureState {- parallelIndex: number;- http_server: {server: TestServer, httpsServer: TestServer};- defaultBrowserOptions: import('../index').LaunchOptions;- playwright: typeof import('../index');- browserType: import('../index').BrowserType<import('../index').Browser>;- browser: import('../index').Browser;- toImpl: (rpcObject: any) => any;- context: import('../index').BrowserContext;- server: TestServer;- page: import('../index').Page;- httpsServer: TestServer;- browserServer: import('../index').BrowserServer;+interface WorkerState {}-interface TestServer {- enableHTTPCache(pathPrefix: string);- setAuth(path: string, username: string, password: string);- enableGzip(path: string);- setCSP(path: string, csp: string);- stop(): Promise<void>;- setRoute(path: string, handler: (message: IncomingMessage, response: ServerResponse) => void);- setRedirect(from: string, to: string);- waitForRequest(path: string): Promise<IncomingMessage>;- reset();- serveFile(request: IncomingMessage, response: ServerResponse, pathName: string);-- PORT: number;- PREFIX: string;- CROSS_PROCESS_PREFIX: string;- EMPTY_PAGE: string;+interface FixtureState {}+declare module '' {module 'expect/build/types' {interface Matchers<R> {@@ -57,18 +31,19 @@ declare const expect: typeof import('expect');declare const describe: DescribeFunction;declare const fdescribe: DescribeFunction;declare const xdescribe: DescribeFunction;-declare const it: ItFunction<FixtureState>;-declare const fit: ItFunction<FixtureState>;-declare const dit: ItFunction<FixtureState>;-declare const xit: ItFunction<FixtureState>;+declare const it: ItFunction<FixtureState & WorkerState>;+declare const fit: ItFunction<FixtureState & WorkerState>;+declare const dit: ItFunction<FixtureState & WorkerState>;+declare const xit: ItFunction<FixtureState & WorkerState>;++declare const beforeEach: (inner: (state: FixtureState & WorkerState) => Promise<void>) => void;+declare const afterEach: (inner: (state: FixtureState & WorkerState) => Promise<void>) => void;+declare const beforeAll: (inner: (state: WorkerState) => Promise<void>) => void;+declare const afterAll: (inner: (state: WorkerState) => Promise<void>) => void;-declare const beforeEach: (inner: (state: FixtureState) => Promise<void>) => void;-declare const afterEach: (inner: (state: FixtureState) => Promise<void>) => void;-declare const beforeAll: (inner: (state: FixtureState) => Promise<void>) => void;-declare const afterAll: (inner: (state: FixtureState) => Promise<void>) => void;+declare const registerFixture: <T extends keyof FixtureState>(name: T, inner: (state: FixtureState & WorkerState, test: (arg: FixtureState[T]) => Promise<void>) => Promise<void>) => void;+declare const registerWorkerFixture: <T extends keyof WorkerState>(name: T, inner: (state: WorkerState, test: (arg: WorkerState[T]) => Promise<void>) => Promise<void>) => void;-declare const registerFixture: <T extends keyof FixtureState>(name: T, inner: (state: FixtureState, test: (arg: FixtureState[T]) => Promise<void>) => Promise<void>) => void;-declare const browserType: import('../index').BrowserType<import('../index').Browser>;// global variables in assets@@ -86,5 +61,7 @@ declare const testOptions: {ASSETS_DIR: string;};+declare const testPath : string;+// keyboard.htmldeclare function getResult(): string;diff --git a/test/wait-for-function.spec.js b/test/wait-for-function.spec.jsindex ae6e838d3f..b1060d52a0 100644--- a/test/wait-for-function.spec.js+++ b/test/wait-for-function.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const utils = require('./utils');const {FFOX, CHROMIUM, WEBKIT, CHANNEL} = testOptions;diff --git a/test/wait-for-selector.spec.js b/test/wait-for-selector.spec.jsindex 094e45b2d6..9ea8f417f1 100644--- a/test/wait-for-selector.spec.js+++ b/test/wait-for-selector.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const utils = require('./utils');const {FFOX, CHROMIUM, WEBKIT, CHANNEL} = testOptions;diff --git a/test/workers.spec.js b/test/workers.spec.jsindex 3fe74d32c1..e6c9da953b 100644--- a/test/workers.spec.js+++ b/test/workers.spec.js@@ -14,6 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/+require('./base.fixture');const {FFOX, CHROMIUM, WEBKIT} = testOptions;diff --git a/utils/testserver/index.d.ts b/utils/testserver/index.d.tsnew file mode 100644index 0000000000..3d1b8614a6--- /dev/null+++ b/utils/testserver/index.d.ts@@ -0,0 +1,34 @@+/**+ * Copyright (c) Microsoft Corporation.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */+export class TestServer {+ static create(dirPath: string, port: number): Promise<TestServer>;+ static createHTTPS(dirPath: string, port: number): Promise<TestServer>;+ enableHTTPCache(pathPrefix: string);+ setAuth(path: string, username: string, password: string);+ enableGzip(path: string);+ setCSP(path: string, csp: string);+ stop(): Promise<void>;+ setRoute(path: string, handler: (message: IncomingMessage, response: ServerResponse) => void);+ setRedirect(from: string, to: string);+ waitForRequest(path: string): Promise<IncomingMessage>;+ reset();+ serveFile(request: IncomingMessage, response: ServerResponse, pathName: string);++ PORT: number;+ PREFIX: string;+ CROSS_PROCESS_PREFIX: string;+ EMPTY_PAGE: string;+}diff --git a/utils/testserver/index.js b/utils/testserver/index.jsindex dfedf5b607..b43bbff636 100644--- a/utils/testserver/index.js+++ b/utils/testserver/index.js@@ -83,6 +83,13 @@ class TestServer {this._gzipRoutes = new Set();/** @type {!Map<string, !Promise>} */this._requestSubscribers = new Map();++ const protocol = sslOptions ? 'https' : 'http';+ this.PORT = port;+ this.PREFIX = `${protocol}://localhost:${port}`;+ this.CROSS_PROCESS_PREFIX = `${protocol}://127.0.0.1:${port}`;+ this.EMPTY_PAGE = `${protocol}://localhost:${port}/empty.html`;+}_onSocket(socket) {