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
test: put test runner api on global, remove unused parameters (#1684)
Dmitry Gozmane0c8fbf1a6ff
diff --git a/test/accessibility.spec.js b/test/accessibility.spec.jsindex b0b68322cc..723f5f843f 100644--- a/test/accessibility.spec.js+++ b/test/accessibility.spec.js@@ -18,10 +18,7 @@/*** @type {PageTestSuite}*/-module.exports.describe = function({testRunner, expect, FFOX, CHROMIUM, WEBKIT, MAC}) {- const {describe, xdescribe, fdescribe} = testRunner;- const {it, fit, xit, dit} = testRunner;- const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;+module.exports.describe = function({FFOX, CHROMIUM, WEBKIT, MAC}) {describe('Accessibility', function() {it('should work', async function({page}) {diff --git a/test/assets/playwrightweb.html b/test/assets/playwrightweb.htmldeleted file mode 100644index b836f9c222..0000000000--- a/test/assets/playwrightweb.html+++ /dev/null@@ -1,12 +0,0 @@-<script src='../../web.js'></script>-<script>-async function setup(product, wsEndpoint) {- window.browser = await window.playwrightweb[product].connect(wsEndpoint);- window.context = await window.browser.newContext();- window.page = await window.context.newPage();-}-async function teardown() {- await window.context.close();- await window.browser.close();-}-</script>\ No newline at end of filediff --git a/test/autowaiting.spec.js b/test/autowaiting.spec.jsindex 7e7725c980..abe307347b 100644--- a/test/autowaiting.spec.js+++ b/test/autowaiting.spec.js@@ -18,10 +18,7 @@/*** @type {PageTestSuite}*/-module.exports.describe = function({testRunner, expect, playwright, MAC, WIN, FFOX, CHROMIUM, WEBKIT}) {- const {describe, xdescribe, fdescribe} = testRunner;- const {it, fit, xit, dit} = testRunner;- const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;+module.exports.describe = function({playwright, MAC, WIN, FFOX, CHROMIUM, WEBKIT}) {describe('Auto waiting', () => {it('should await navigation when clicking anchor', async({page, server}) => {diff --git a/test/browser.spec.js b/test/browser.spec.jsindex f5e032ef8e..fbbd64dd26 100644--- a/test/browser.spec.js+++ b/test/browser.spec.js@@ -14,15 +14,10 @@* limitations under the License.*/-const utils = require('./utils');-/*** @type {BrowserTestSuite}*/-module.exports.describe = function({testRunner, expect, playwright, CHROMIUM, WEBKIT}) {- const {describe, xdescribe, fdescribe} = testRunner;- const {it, fit, xit, dit} = testRunner;- const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;+module.exports.describe = function({playwright, CHROMIUM, WEBKIT}) {describe('Browser.newPage', function() {it('should create new page', async function({browser}) {diff --git a/test/browsercontext.spec.js b/test/browsercontext.spec.jsindex d733fd53cb..7e36459df4 100644--- a/test/browsercontext.spec.js+++ b/test/browsercontext.spec.js@@ -20,10 +20,7 @@ const utils = require('./utils');/*** @type {BrowserTestSuite}*/-module.exports.describe = function({testRunner, expect, playwright, CHROMIUM, FFOX, WEBKIT, LINUX}) {- const {describe, xdescribe, fdescribe} = testRunner;- const {it, fit, xit, dit} = testRunner;- const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;+module.exports.describe = function({playwright, CHROMIUM, FFOX, WEBKIT, LINUX}) {describe('BrowserContext', function() {it('should create new context', async function({browser}) {diff --git a/test/capabilities.spec.js b/test/capabilities.spec.jsindex e4cd4169f4..c11c5d1cb0 100644--- a/test/capabilities.spec.js+++ b/test/capabilities.spec.js@@ -14,16 +14,10 @@* limitations under the License.*/-const utils = require('./utils');-const { waitEvent } = utils;-/*** @type {PageTestSuite}*/-module.exports.describe = function({testRunner, expect, WIN, WEBKIT}) {- const {describe, xdescribe, fdescribe} = testRunner;- const {it, fit, xit, dit} = testRunner;- const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;+module.exports.describe = function({WIN, WEBKIT}) {describe('Capabilities', function() {it.fail(WEBKIT && WIN)('Web Assembly should work', async function({page, server}) {diff --git a/test/chromium/chromium.spec.js b/test/chromium/chromium.spec.jsindex f8940ff889..75aa0fe145 100644--- a/test/chromium/chromium.spec.js+++ b/test/chromium/chromium.spec.js@@ -14,15 +14,10 @@* limitations under the License.*/-const { waitEvent } = require('../utils');-/*** @type {ChromiumTestSuite}*/-module.exports.describe = function({testRunner, expect, playwright, FFOX, CHROMIUM, WEBKIT}) {- const {describe, xdescribe, fdescribe} = testRunner;- const {it, fit, xit, dit} = testRunner;- const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;+module.exports.describe = function({playwright, FFOX, CHROMIUM, WEBKIT}) {describe('ChromiumBrowserContext', function() {it('should create a worker from a service worker', async({browser, page, server, context}) => {diff --git a/test/chromium/coverage.spec.js b/test/chromium/coverage.spec.jsindex 9b5a501ac3..fa3b4aa6d2 100644--- a/test/chromium/coverage.spec.js+++ b/test/chromium/coverage.spec.js@@ -17,10 +17,7 @@/*** @type {ChromiumTestSuite}*/-module.exports.describe = function({testRunner, expect, FFOX, CHROMIUM, WEBKIT}) {- const {describe, xdescribe, fdescribe} = testRunner;- const {it, fit, xit, dit} = testRunner;- const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;+module.exports.describe = function({FFOX, CHROMIUM, WEBKIT}) {describe('JSCoverage', function() {it('should work', async function({page, server}) {diff --git a/test/chromium/launcher.spec.js b/test/chromium/launcher.spec.jsindex d5c81432ad..c1472fc820 100644--- a/test/chromium/launcher.spec.js+++ b/test/chromium/launcher.spec.js@@ -18,21 +18,12 @@ const util = require('util');const fs = require('fs');const path = require('path');const os = require('os');-const readFileAsync = util.promisify(fs.readFile);-const rmAsync = util.promisify(require('rimraf'));-const mkdtempAsync = util.promisify(fs.mkdtemp);-const statAsync = util.promisify(fs.stat);const { makeUserDataDir, removeUserDataDir } = require('../utils');-const TMP_FOLDER = path.join(os.tmpdir(), 'pw_tmp_folder-');-/*** @type {TestSuite}*/-module.exports.describe = function({testRunner, expect, defaultBrowserOptions, browserType, WIN}) {- const {describe, xdescribe, fdescribe} = testRunner;- const {it, fit, xit, dit} = testRunner;- const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;+module.exports.describe = function({defaultBrowserOptions, browserType, WIN}) {const headfulOptions = Object.assign({}, defaultBrowserOptions, {headless: falsediff --git a/test/chromium/oopif.spec.js b/test/chromium/oopif.spec.jsindex 3e3c2c243a..ef99e8269a 100644--- a/test/chromium/oopif.spec.js+++ b/test/chromium/oopif.spec.js@@ -17,10 +17,7 @@/*** @type {ChromiumTestSuite}*/-module.exports.describe = function({testRunner, expect, defaultBrowserOptions, browserType, FFOX, CHROMIUM, WEBKIT}) {- const {describe, xdescribe, fdescribe} = testRunner;- const {it, fit, xit, dit} = testRunner;- const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;+module.exports.describe = function({defaultBrowserOptions, browserType, FFOX, CHROMIUM, WEBKIT}) {const headfulOptions = Object.assign({}, defaultBrowserOptions, {headless: falsediff --git a/test/chromium/pdf.spec.js b/test/chromium/pdf.spec.jsindex 6ffde1d5f2..907288030a 100644--- a/test/chromium/pdf.spec.js+++ b/test/chromium/pdf.spec.js@@ -20,15 +20,12 @@ const path = require('path');/*** @type {ChromiumTestSuite}*/-module.exports.describe = function({testRunner, expect, headless, ASSETS_DIR}) {- const {describe, xdescribe, fdescribe} = testRunner;- const {it, fit, xit, dit} = testRunner;- const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;+module.exports.describe = function({headless, OUTPUT_DIR}) {// Printing to pdf is currently only supported in headlessdescribe.fail(!headless)('Page.pdf', function() {it('should be able to save file', async({page, server}) => {- const outputFile = path.join(ASSETS_DIR, 'output.pdf');+ const outputFile = path.join(OUTPUT_DIR, 'output.pdf');await page.pdf({path: outputFile});expect(fs.readFileSync(outputFile).byteLength).toBeGreaterThan(0);fs.unlinkSync(outputFile);diff --git a/test/chromium/session.spec.js b/test/chromium/session.spec.jsindex b9e1b5ca94..6f41bc7624 100644--- a/test/chromium/session.spec.js+++ b/test/chromium/session.spec.js@@ -19,10 +19,7 @@ const { waitEvent } = require('../utils');/*** @type {ChromiumTestSuite}*/-module.exports.describe = function({testRunner, expect, FFOX, CHROMIUM, WEBKIT}) {- const {describe, xdescribe, fdescribe} = testRunner;- const {it, fit, xit, dit} = testRunner;- const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;+module.exports.describe = function({FFOX, CHROMIUM, WEBKIT}) {describe('ChromiumBrowserContext.createSession', function() {it('should work', async function({page, browser, server}) {diff --git a/test/chromium/tracing.spec.js b/test/chromium/tracing.spec.jsindex 55075a25e0..dec98ef7bd 100644--- a/test/chromium/tracing.spec.js+++ b/test/chromium/tracing.spec.js@@ -20,14 +20,11 @@ const path = require('path');/*** @type {ChromiumTestSuite}*/-module.exports.describe = function({testRunner, expect, defaultBrowserOptions, browserType, ASSETS_DIR}) {- const {describe, xdescribe, fdescribe} = testRunner;- const {it, fit, xit, dit} = testRunner;- const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;+module.exports.describe = function({defaultBrowserOptions, browserType, OUTPUT_DIR}) {describe('Chromium.startTracing', function() {beforeEach(async function(state) {- state.outputFile = path.join(ASSETS_DIR, `trace-${state.parallelIndex}.json`);+ state.outputFile = path.join(OUTPUT_DIR, `trace-${state.parallelIndex}.json`);state.browser = await browserType.launch(defaultBrowserOptions);state.page = await state.browser.newPage();});diff --git a/test/click.spec.js b/test/click.spec.jsindex efdff4f3f2..af4e8d9cd6 100644--- a/test/click.spec.js+++ b/test/click.spec.js@@ -20,10 +20,7 @@ const utils = require('./utils');/*** @type {PageTestSuite}*/-module.exports.describe = function({testRunner, expect, playwright, FFOX, CHROMIUM, WEBKIT}) {- const {describe, xdescribe, fdescribe} = testRunner;- const {it, fit, xit, dit} = testRunner;- const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;+ module.exports.describe = function({playwright, FFOX, CHROMIUM, WEBKIT}) {describe('Page.click', function() {it('should click the button', async({page, server}) => {diff --git a/test/cookies.spec.js b/test/cookies.spec.jsindex deeb4a529a..69ecf331a7 100644--- a/test/cookies.spec.js+++ b/test/cookies.spec.js@@ -18,10 +18,7 @@/*** @type {PageTestSuite}*/-module.exports.describe = function({testRunner, expect, browserType, defaultBrowserOptions, MAC, FFOX, CHROMIUM, WEBKIT}) {- const {describe, xdescribe, fdescribe} = testRunner;- const {it, fit, xit, dit} = testRunner;- const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;+module.exports.describe = function({browserType, defaultBrowserOptions, MAC, FFOX, CHROMIUM, WEBKIT}) {describe('BrowserContext.cookies', function() {it('should return no cookies in pristine browser context', async({context, page, server}) => {diff --git a/test/defaultbrowsercontext.spec.js b/test/defaultbrowsercontext.spec.jsindex 7634a79e6a..02c49cf118 100644--- a/test/defaultbrowsercontext.spec.js+++ b/test/defaultbrowsercontext.spec.js@@ -20,10 +20,7 @@ const { makeUserDataDir, removeUserDataDir } = require('./utils');/*** @type {PageTestSuite}*/-module.exports.describe = function ({ testRunner, expect, defaultBrowserOptions, browserType, WEBKIT }) {- const {describe, xdescribe, fdescribe} = testRunner;- const {it, fit, xit, dit} = testRunner;- const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;+module.exports.describe = function ({ defaultBrowserOptions, browserType, WEBKIT }) {describe('launchPersistentContext()', function() {beforeEach(async state => {diff --git a/test/dialog.spec.js b/test/dialog.spec.jsindex 6a131cbc02..8765f5b144 100644--- a/test/dialog.spec.js+++ b/test/dialog.spec.js@@ -18,10 +18,7 @@/*** @type {PageTestSuite}*/-module.exports.describe = function({testRunner, expect, FFOX, CHROMIUM, WEBKIT}) {- const {describe, xdescribe, fdescribe} = testRunner;- const {it, fit, xit, dit} = testRunner;- const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;+module.exports.describe = function({FFOX, CHROMIUM, WEBKIT}) {describe('Page.Events.Dialog', function() {it('should fire', async({page, server}) => {diff --git a/test/download.spec.js b/test/download.spec.jsindex 1d4337de27..fdd84b7e95 100644--- a/test/download.spec.js+++ b/test/download.spec.js@@ -17,10 +17,7 @@const fs = require('fs');const path = require('path');-module.exports.describe = function({testRunner, expect, browserType, CHROMIUM, WEBKIT, FFOX, WIN, MAC}) {- const {describe, xdescribe, fdescribe} = testRunner;- const {it, fit, xit, dit} = testRunner;- const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;+module.exports.describe = function({browserType, CHROMIUM, WEBKIT, FFOX, WIN, MAC}) {describe.fail(FFOX)('Download', function() {beforeEach(async(state) => {diff --git a/test/elementhandle.spec.js b/test/elementhandle.spec.jsindex ae83bf9ff8..0eaf5e31f4 100644--- a/test/elementhandle.spec.js+++ b/test/elementhandle.spec.js@@ -20,10 +20,7 @@ const utils = require('./utils');/*** @type {PageTestSuite}*/-module.exports.describe = function({testRunner, expect, FFOX, CHROMIUM, WEBKIT}) {- const {describe, xdescribe, fdescribe} = testRunner;- const {it, fit, xit, dit} = testRunner;- const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;+module.exports.describe = function({FFOX, CHROMIUM, WEBKIT}) {describe('ElementHandle.boundingBox', function() {it('should work', async({page, server}) => {diff --git a/test/emulation.spec.js b/test/emulation.spec.jsindex 668d41852e..ae04cf7fa9 100644--- a/test/emulation.spec.js+++ b/test/emulation.spec.js@@ -20,10 +20,7 @@ const utils = require('./utils');/*** @type {PageTestSuite}*/-module.exports.describe = function({testRunner, expect, playwright, headless, FFOX, CHROMIUM, WEBKIT, MAC, WIN}) {- const {describe, xdescribe, fdescribe} = testRunner;- const {it, fit, xit, dit} = testRunner;- const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;+module.exports.describe = function({playwright, headless, FFOX, CHROMIUM, WEBKIT, MAC, WIN}) {const iPhone = playwright.devices['iPhone 6'];const iPhoneLandscape = playwright.devices['iPhone 6 landscape'];diff --git a/test/evaluation.spec.js b/test/evaluation.spec.jsindex b77124cc53..480f95ee79 100644--- a/test/evaluation.spec.js+++ b/test/evaluation.spec.js@@ -17,15 +17,11 @@const utils = require('./utils');const path = require('path');-const bigint = typeof BigInt !== 'undefined';/*** @type {PageTestSuite}*/-module.exports.describe = function({testRunner, expect, FFOX, CHROMIUM, WEBKIT, LINUX}) {- const {describe, xdescribe, fdescribe} = testRunner;- const {it, fit, xit, dit} = testRunner;- const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;+module.exports.describe = function({FFOX, CHROMIUM, WEBKIT, LINUX}) {describe('Page.evaluate', function() {it('should work', async({page, server}) => {diff --git a/test/fixtures.spec.js b/test/fixtures.spec.jsindex f360ba0f7d..188774cb15 100644--- a/test/fixtures.spec.js+++ b/test/fixtures.spec.js@@ -21,10 +21,7 @@ const {spawn, execSync} = require('child_process');/*** @type {TestSuite}*/-module.exports.describe = function({testRunner, expect, product, browserType, playwrightPath, defaultBrowserOptions, WIN, FFOX, CHROMIUM, WEBKIT}) {- const {describe, xdescribe, fdescribe} = testRunner;- const {it, fit, xit, dit} = testRunner;- const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;+module.exports.describe = function({browserType, playwrightPath, defaultBrowserOptions, WIN, FFOX, CHROMIUM, WEBKIT}) {async function testSignal(action, exitOnClose) {const options = Object.assign({}, defaultBrowserOptions, {@@ -34,7 +31,7 @@ module.exports.describe = function({testRunner, expect, product, browserType, plhandleSIGTERM: true,handleSIGHUP: true,});- const res = spawn('node', [path.join(__dirname, 'fixtures', 'closeme.js'), playwrightPath, product, JSON.stringify(options), exitOnClose ? 'true' : '']);+ const res = spawn('node', [path.join(__dirname, 'fixtures', 'closeme.js'), playwrightPath, browserType.name(), JSON.stringify(options), exitOnClose ? 'true' : '']);let wsEndPointCallback;const wsEndPointPromise = new Promise(x => wsEndPointCallback = x);let output = '';@@ -71,14 +68,7 @@ module.exports.describe = function({testRunner, expect, product, browserType, pldescribe('Fixtures', function() {it.slow()('should dump browser process stderr', async({server}) => {let dumpioData = '';- const res = spawn('node', [path.join(__dirname, 'fixtures', 'dumpio.js'), playwrightPath, product, 'usewebsocket']);- res.stdout.on('data', data => dumpioData += data.toString('utf8'));- await new Promise(resolve => res.on('close', resolve));- expect(dumpioData).toContain('message from dumpio');- });- it.slow()('should dump browser process stderr', async({server}) => {- let dumpioData = '';- const res = spawn('node', [path.join(__dirname, 'fixtures', 'dumpio.js'), playwrightPath, product]);+ const res = spawn('node', [path.join(__dirname, 'fixtures', 'dumpio.js'), playwrightPath, browserType.name()]);res.stdout.on('data', data => dumpioData += data.toString('utf8'));await new Promise(resolve => res.on('close', resolve));expect(dumpioData).toContain('message from dumpio');diff --git a/test/fixtures/closeme.js b/test/fixtures/closeme.jsindex 34dc1d599d..f1f3f2c422 100644--- a/test/fixtures/closeme.js+++ b/test/fixtures/closeme.js@@ -1,6 +1,6 @@(async() => {- const [, , playwrightRoot, product, options, exitOnClose] = process.argv;- const browserServer = await require(playwrightRoot)[product.toLowerCase()].launchServer(JSON.parse(options));+ const [, , playwrightRoot, browserType, options, exitOnClose] = process.argv;+ const browserServer = await require(playwrightRoot)[browserType].launchServer(JSON.parse(options));browserServer.on('close', (exitCode, signal) => {console.log(`browserClose:${exitCode}:${signal}:browserClose`);if (exitOnClose)diff --git a/test/fixtures/dumpio.js b/test/fixtures/dumpio.jsindex 1bb380233b..41b36ab2d0 100644--- a/test/fixtures/dumpio.js+++ b/test/fixtures/dumpio.js@@ -4,7 +4,7 @@console.log('unhandledRejection', error.message);});- const [, , playwrightRoot, product, useWebSocket] = process.argv;+ const [, , playwrightRoot, browserType] = process.argv;const options = {ignoreDefaultArgs: true,dumpio: true,@@ -12,9 +12,8 @@executablePath: 'node',args: ['-e', 'console.error("message from dumpio")', '--']}- console.error('using web socket: ' + options.webSocket);try {- await require(playwrightRoot)[product.toLowerCase()].launchServer(options);+ await require(playwrightRoot)[browserType].launchServer(options);console.error('Browser launch unexpectedly succeeded.');} catch (e) {}diff --git a/test/focus.spec.js b/test/focus.spec.jsindex 250a522e58..8272755578 100644--- a/test/focus.spec.js+++ b/test/focus.spec.js@@ -14,16 +14,10 @@* limitations under the License.*/-const utils = require('./utils');-const { waitEvent } = utils;-/*** @type {PageTestSuite}*/-module.exports.describe = function({testRunner, expect}) {- const {describe, xdescribe, fdescribe} = testRunner;- const {it, fit, xit, dit} = testRunner;- const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;+module.exports.describe = function({}) {describe('Page.focus', function() {it('should work', async function({page, server}) {diff --git a/test/frame.spec.js b/test/frame.spec.jsindex 308f3c55df..b9241e6bc9 100644--- a/test/frame.spec.js+++ b/test/frame.spec.js@@ -20,10 +20,7 @@ const utils = require('./utils');/*** @type {PageTestSuite}*/-module.exports.describe = function({testRunner, expect, FFOX, CHROMIUM, WEBKIT}) {- const {describe, xdescribe, fdescribe} = testRunner;- const {it, fit, xit, dit} = testRunner;- const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;+module.exports.describe = function({FFOX, CHROMIUM, WEBKIT}) {describe('Frame.evaluateHandle', function() {it('should work', async({page, server}) => {diff --git a/test/geolocation.spec.js b/test/geolocation.spec.jsindex 654ce4f878..17d4b9ffa2 100644--- a/test/geolocation.spec.js+++ b/test/geolocation.spec.js@@ -18,10 +18,7 @@/*** @type {PageTestSuite}*/-module.exports.describe = function ({ testRunner, expect, FFOX, WEBKIT }) {- const {describe, xdescribe, fdescribe} = testRunner;- const {it, fit, xit, dit} = testRunner;- const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;+module.exports.describe = function ({ FFOX, WEBKIT }) {describe('Overrides.setGeolocation', function() {it('should work', async({page, server, context}) => {diff --git a/test/headful.spec.js b/test/headful.spec.jsindex f6270f4c10..046157073d 100644--- a/test/headful.spec.js+++ b/test/headful.spec.js@@ -19,10 +19,7 @@ const { makeUserDataDir, removeUserDataDir } = require('./utils');/*** @type {TestSuite}*/-module.exports.describe = function({testRunner, expect, browserType, defaultBrowserOptions, FFOX, CHROMIUM, WEBKIT, WIN}) {- const {describe, xdescribe, fdescribe} = testRunner;- const {it, fit, xit, dit} = testRunner;- const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;+module.exports.describe = function({browserType, defaultBrowserOptions, FFOX, CHROMIUM, WEBKIT, WIN}) {const headfulOptions = Object.assign({}, defaultBrowserOptions, {headless: falsediff --git a/test/ignorehttpserrors.spec.js b/test/ignorehttpserrors.spec.jsindex 8ba5b4c6b4..8d8cd1b67a 100644--- a/test/ignorehttpserrors.spec.js+++ b/test/ignorehttpserrors.spec.js@@ -18,10 +18,8 @@/*** @type {BrowserTestSuite}*/-module.exports.describe = function({testRunner, expect, defaultBrowserOptions, playwright, FFOX, CHROMIUM, WEBKIT}) {- const {describe, xdescribe, fdescribe} = testRunner;- const {it, fit, xit, dit} = testRunner;- const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;+module.exports.describe = function({defaultBrowserOptions, playwright, FFOX, CHROMIUM, WEBKIT}) {+describe('ignoreHTTPSErrors', function() {it('should work', async({browser, httpsServer}) => {let error = null;@@ -40,7 +38,7 @@ module.exports.describe = function({testRunner, expect, defaultBrowserOptions, pconst response = await page.goto(httpsServer.EMPTY_PAGE).catch(e => error = e);expect(error).toBe(null);expect(response.ok()).toBe(true);- await context.close();+ await context.close();}{let error = null;@@ -48,7 +46,7 @@ module.exports.describe = function({testRunner, expect, defaultBrowserOptions, pconst page = await context.newPage();await page.goto(httpsServer.EMPTY_PAGE).catch(e => error = e);expect(error).not.toBe(null);- await context.close();+ await context.close();}});it('should work with mixed content', async({browser, server, httpsServer}) => {diff --git a/test/input.spec.js b/test/input.spec.jsindex 5b5878f50b..d047d17a97 100644--- a/test/input.spec.js+++ b/test/input.spec.js@@ -24,10 +24,8 @@ const FILE_TO_UPLOAD = path.join(__dirname, '/assets/file-to-upload.txt');/*** @type {PageTestSuite}*/-module.exports.describe = function({testRunner, expect, playwright, FFOX, CHROMIUM, WEBKIT}) {- const {describe, xdescribe, fdescribe} = testRunner;- const {it, fit, xit, dit} = testRunner;- const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;+module.exports.describe = function({playwright, FFOX, CHROMIUM, WEBKIT}) {+describe('input', function() {it('should upload the file', async({page, server}) => {await page.goto(server.PREFIX + '/input/fileupload.html');diff --git a/test/interception.spec.js b/test/interception.spec.jsindex 6f35754bf3..f75c711ada 100644--- a/test/interception.spec.js+++ b/test/interception.spec.js@@ -24,10 +24,7 @@ const vm = require('vm');/*** @type {PageTestSuite}*/-module.exports.describe = function({testRunner, expect, defaultBrowserOptions, playwright, FFOX, CHROMIUM, WEBKIT}) {- const {describe, xdescribe, fdescribe} = testRunner;- const {it, fit, xit, dit} = testRunner;- const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;+module.exports.describe = function({defaultBrowserOptions, playwright, FFOX, CHROMIUM, WEBKIT}) {describe('Page.route', function() {it('should intercept', async({page, server}) => {diff --git a/test/jshandle.spec.js b/test/jshandle.spec.jsindex eefb0f47f0..fd1c795ee6 100644--- a/test/jshandle.spec.js+++ b/test/jshandle.spec.js@@ -18,10 +18,7 @@/*** @type {PageTestSuite}*/-module.exports.describe = function({testRunner, expect, CHROMIUM, FFOX, WEBKIT}) {- const {describe, xdescribe, fdescribe} = testRunner;- const {it, fit, xit, dit} = testRunner;- const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;+module.exports.describe = function({CHROMIUM, FFOX, WEBKIT}) {describe('Page.evaluateHandle', function() {it('should work', async({page, server}) => {diff --git a/test/keyboard.spec.js b/test/keyboard.spec.jsindex ca45d3fe22..9d1e0e2d9c 100644--- a/test/keyboard.spec.js+++ b/test/keyboard.spec.js@@ -21,10 +21,7 @@ const os = require('os');/*** @type {PageTestSuite}*/-module.exports.describe = function({testRunner, expect, FFOX, CHROMIUM, WEBKIT, MAC}) {- const {describe, xdescribe, fdescribe} = testRunner;- const {it, fit, xit, dit} = testRunner;- const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;+module.exports.describe = function({FFOX, CHROMIUM, WEBKIT, MAC}) {describe('Keyboard', function() {it('should type into a textarea', async({page, server}) => {diff --git a/test/launcher.spec.js b/test/launcher.spec.jsindex b954e67b27..b17e2fa12a 100644--- a/test/launcher.spec.js+++ b/test/launcher.spec.js@@ -23,10 +23,7 @@ const { makeUserDataDir, removeUserDataDir } = require('./utils');/*** @type {TestSuite}*/-module.exports.describe = function({testRunner, expect, defaultBrowserOptions, playwright, browserType, playwrightPath, product, CHROMIUM, FFOX, WEBKIT, WIN}) {- const {describe, xdescribe, fdescribe} = testRunner;- const {it, fit, xit, dit} = testRunner;- const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;+module.exports.describe = function({defaultBrowserOptions, playwright, browserType, playwrightPath, CHROMIUM, FFOX, WEBKIT, WIN}) {describe('Playwright', function() {describe('browserType.launch', function() {diff --git a/test/mouse.spec.js b/test/mouse.spec.jsindex e9de987758..66c818d32a 100644--- a/test/mouse.spec.js+++ b/test/mouse.spec.js@@ -14,7 +14,6 @@* See the License for the specific language governing permissions and* limitations under the License.*/-const os = require('os');function dimensions() {const rect = document.querySelector('textarea').getBoundingClientRect();@@ -29,10 +28,7 @@ function dimensions() {/*** @type {PageTestSuite}*/-module.exports.describe = function({testRunner, expect, FFOX, CHROMIUM, WEBKIT, MAC}) {- const {describe, xdescribe, fdescribe} = testRunner;- const {it, fit, xit, dit} = testRunner;- const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;+module.exports.describe = function({FFOX, CHROMIUM, WEBKIT, MAC}) {describe('Mouse', function() {it('should click the document', async({page, server}) => {diff --git a/test/multiclient.spec.js b/test/multiclient.spec.jsindex 7093e20849..58372f2670 100644--- a/test/multiclient.spec.js+++ b/test/multiclient.spec.js@@ -20,10 +20,7 @@ const utils = require('./utils');/*** @type {TestSuite}*/-module.exports.describe = function({testRunner, expect, defaultBrowserOptions, browserType, FFOX, CHROMIUM, WEBKIT}) {- const {describe, xdescribe, fdescribe} = testRunner;- const {it, fit, xit, dit} = testRunner;- const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;+module.exports.describe = function({defaultBrowserOptions, browserType, FFOX, CHROMIUM, WEBKIT}) {describe('BrowserContext', function() {it('should work across sessions', async () => {diff --git a/test/navigation.spec.js b/test/navigation.spec.jsindex 0d1f132ffa..61592685d1 100644--- a/test/navigation.spec.js+++ b/test/navigation.spec.js@@ -22,10 +22,7 @@ const url = require('url');/*** @type {PageTestSuite}*/-module.exports.describe = function({testRunner, expect, playwright, MAC, WIN, FFOX, CHROMIUM, WEBKIT}) {- const {describe, xdescribe, fdescribe} = testRunner;- const {it, fit, xit, dit} = testRunner;- const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;+module.exports.describe = function({playwright, MAC, WIN, FFOX, CHROMIUM, WEBKIT}) {describe('Page.goto', function() {it('should work', async({page, server}) => {diff --git a/test/network.spec.js b/test/network.spec.jsindex a833f3d5af..4187a144a6 100644--- a/test/network.spec.js+++ b/test/network.spec.js@@ -22,10 +22,7 @@ const utils = require('./utils');/*** @type {PageTestSuite}*/-module.exports.describe = function({testRunner, expect, MAC, WIN, FFOX, CHROMIUM, WEBKIT}) {- const {describe, xdescribe, fdescribe} = testRunner;- const {it, fit, xit, dit} = testRunner;- const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;+module.exports.describe = function({MAC, WIN, FFOX, CHROMIUM, WEBKIT}) {describe('Page.Events.Request', function() {it('should fire for navigation requests', async({page, server}) => {diff --git a/test/page.spec.js b/test/page.spec.jsindex 567742c8f5..833afdc5eb 100644--- a/test/page.spec.js+++ b/test/page.spec.js@@ -14,7 +14,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/-const fs = require('fs');+const path = require('path');const utils = require('./utils');const {waitEvent} = utils;@@ -23,10 +23,7 @@ const vm = require('vm');/*** @type {PageTestSuite}*/-module.exports.describe = function({testRunner, expect, headless, playwright, FFOX, CHROMIUM, WEBKIT}) {- const {describe, xdescribe, fdescribe} = testRunner;- const {it, fit, xit, dit} = testRunner;- const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;+module.exports.describe = function({playwright, FFOX, CHROMIUM, WEBKIT}) {describe('Page.close', function() {it('should reject all promises when page is closed', async({context}) => {diff --git a/test/permissions.spec.js b/test/permissions.spec.jsindex 3aca18f225..2a96f8e5c7 100644--- a/test/permissions.spec.js+++ b/test/permissions.spec.js@@ -15,16 +15,10 @@* limitations under the License.*/-const fs = require('fs');-const path = require('path');-/*** @type {PageTestSuite}*/-module.exports.describe = function({testRunner, expect, WEBKIT, FFOX}) {- const {describe, xdescribe, fdescribe} = testRunner;- const {it, fit, xit, dit} = testRunner;- const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;+module.exports.describe = function({WEBKIT, FFOX}) {// Permissions API is not implemented in WebKit (see https://developer.mozilla.org/en-US/docs/Web/API/Permissions_API)describe.skip(WEBKIT)('Permissions', function() {diff --git a/test/playwright.spec.js b/test/playwright.spec.jsindex 5428fb2726..f0cf61e1b3 100644--- a/test/playwright.spec.js+++ b/test/playwright.spec.js@@ -49,11 +49,7 @@ const browserNames = BROWSER_CONFIGS.map(config => config.name);/*** @type {TestSuite}*/-module.exports.addPlaywrightTests = ({testRunner, platform, products, playwrightPath, headless, slowMo, dumpProtocolOnFailure, coverage}) => {- const {describe, xdescribe, fdescribe} = testRunner;- const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;- const {expect} = testRunner;-+module.exports.addPlaywrightTests = ({platform, products, playwrightPath, headless, slowMo, dumpProtocolOnFailure, coverage}) => {const MAC = platform === 'darwin';const LINUX = platform === 'linux';const WIN = platform === 'win32';@@ -121,14 +117,12 @@ module.exports.addPlaywrightTests = ({testRunner, platform, products, playwrightconst GOLDEN_DIR = path.join(__dirname, 'golden-' + product.toLowerCase());const OUTPUT_DIR = path.join(__dirname, 'output-' + product.toLowerCase());- const ASSETS_DIR = path.join(__dirname, 'assets');if (fs.existsSync(OUTPUT_DIR))rm(OUTPUT_DIR);+ fs.mkdirSync(OUTPUT_DIR, { recursive: true });expect.setupGolden(GOLDEN_DIR, OUTPUT_DIR);const testOptions = {- testRunner,- product,FFOX,WEBKIT,CHROMIUM,@@ -137,11 +131,10 @@ module.exports.addPlaywrightTests = ({testRunner, platform, products, playwrightWIN,browserType,playwright,- expect,defaultBrowserOptions,playwrightPath,headless: !!defaultBrowserOptions.headless,- ASSETS_DIR,+ OUTPUT_DIR,};function loadTests(modulePath) {@@ -281,7 +274,7 @@ module.exports.addPlaywrightTests = ({testRunner, platform, products, playwrightreturn;filteredApi[apiName] = api[apiName];});- require('./utils').recordAPICoverage(testRunner, filteredApi, browserConfig.events, browserConfig.missingCoverage);+ require('./utils').recordAPICoverage(filteredApi, browserConfig.events, browserConfig.missingCoverage);}});}diff --git a/test/popup.spec.js b/test/popup.spec.jsindex b158cc1dbb..ed680c7318 100644--- a/test/popup.spec.js+++ b/test/popup.spec.js@@ -14,10 +14,7 @@* limitations under the License.*/-module.exports.describe = function({testRunner, expect, playwright, CHROMIUM, WEBKIT, FFOX}) {- const {describe, xdescribe, fdescribe} = testRunner;- const {it, fit, xit, dit} = testRunner;- const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;+module.exports.describe = function({playwright, CHROMIUM, WEBKIT, FFOX}) {describe('Link navigation', function() {it('should inherit user agent from browser context', async function({browser, server}) {diff --git a/test/queryselector.spec.js b/test/queryselector.spec.jsindex e5ee9828f9..14f2cee415 100644--- a/test/queryselector.spec.js+++ b/test/queryselector.spec.js@@ -21,10 +21,7 @@ const zsSelectorEngineSource = require('../lib/generated/zsSelectorEngineSource'/*** @type {PageTestSuite}*/-module.exports.describe = function({testRunner, expect, playwright, FFOX, CHROMIUM, WEBKIT}) {- const {describe, xdescribe, fdescribe} = testRunner;- const {it, fit, xit, dit} = testRunner;- const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;+module.exports.describe = function({playwright, FFOX, CHROMIUM, WEBKIT}) {describe('Page.$eval', function() {it('should work with css selector', async({page, server}) => {diff --git a/test/screenshot.spec.js b/test/screenshot.spec.jsindex e0059bfe4a..cd73e49b56 100644--- a/test/screenshot.spec.js+++ b/test/screenshot.spec.js@@ -18,10 +18,7 @@/*** @type {PageTestSuite}*/-module.exports.describe = function({testRunner, expect, product, playwright, FFOX, CHROMIUM, WEBKIT, LINUX }) {- const {describe, xdescribe, fdescribe} = testRunner;- const {it, fit, xit, dit} = testRunner;- const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;+module.exports.describe = function({FFOX, CHROMIUM, WEBKIT, LINUX }) {describe('Page.screenshot', function() {it('should work', async({page, server}) => {diff --git a/test/test.js b/test/test.jsindex 2bf761782f..2ccd61436b 100644--- a/test/test.js+++ b/test/test.js@@ -68,16 +68,22 @@ function valueFromEnv(name, defaultValue) {return JSON.parse(process.env[name]);}+for (const [key, value] of Object.entries(testRunner.api()))+ global[key] = value;require('./playwright.spec.js').addPlaywrightTests({playwrightPath: utils.projectRoot(),products,platform: os.platform(),- testRunner: testRunner.api(),headless: !!valueFromEnv('HEADLESS', true),slowMo: valueFromEnv('SLOW_MO', 0),dumpProtocolOnFailure: valueFromEnv('DEBUGP', false),coverage: process.env.COVERAGE,});+for (const [key, value] of Object.entries(testRunner.api())) {+ // expect is used when running tests, while the rest of api is not.+ if (key !== 'expect')+ delete global[key];+}const filterArgIndex = process.argv.indexOf('--filter');if (filterArgIndex !== -1) {@@ -86,4 +92,4 @@ if (filterArgIndex !== -1) {}// await utils.initializeFlakinessDashboardIfNeeded(testRunner);-testRunner.run();+testRunner.run().then(() => { delete global.expect; });diff --git a/test/utils.js b/test/utils.jsindex f44e88a10f..6efa9a0f52 100644--- a/test/utils.js+++ b/test/utils.js@@ -80,13 +80,13 @@ const utils = module.exports = {return promisified;},- recordAPICoverage: function(testRunner, api, events, ignoredMethodsArray = []) {+ recordAPICoverage: function(api, events, ignoredMethodsArray = []) {const coverage = new Map();const ignoredMethods = new Set(ignoredMethodsArray);for (const [className, classType] of Object.entries(api))traceAPICoverage(coverage, events, className, classType);- testRunner.describe(COVERAGE_TESTSUITE_NAME, () => {- testRunner.it('should call all API methods', () => {+ describe(COVERAGE_TESTSUITE_NAME, () => {+ it('should call all API methods', () => {const missingMethods = [];const extraIgnoredMethods = [];for (const method of coverage.keys()) {diff --git a/test/waittask.spec.js b/test/waittask.spec.jsindex 9244838e48..f4aede4683 100644--- a/test/waittask.spec.js+++ b/test/waittask.spec.js@@ -20,10 +20,7 @@ const utils = require('./utils');/*** @type {PageTestSuite}*/-module.exports.describe = function({testRunner, expect, product, playwright, FFOX, CHROMIUM, WEBKIT}) {- const {describe, xdescribe, fdescribe} = testRunner;- const {it, fit, xit, dit} = testRunner;- const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;+module.exports.describe = function({playwright, FFOX, CHROMIUM, WEBKIT}) {describe('Page.waitFor', function() {it('should wait for selector', async({page, server}) => {diff --git a/test/workers.spec.js b/test/workers.spec.jsindex 551c5cae4b..91900e1d7e 100644--- a/test/workers.spec.js+++ b/test/workers.spec.js@@ -21,10 +21,7 @@ const { waitEvent } = utils;/*** @type {PageTestSuite}*/-module.exports.describe = function({testRunner, expect, FFOX, CHROMIUM, WEBKIT, LINUX}) {- const {describe, xdescribe, fdescribe} = testRunner;- const {it, fit, xit, dit} = testRunner;- const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;+module.exports.describe = function({FFOX, CHROMIUM, WEBKIT, LINUX}) {describe('Workers', function() {it('Page.workers', async function({page, server}) {