diff --git a/test/accessibility.spec.js b/test/accessibility.spec.js index b0b68322cc1ae..723f5f843f0c2 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.html deleted file mode 100644 index b836f9c222e72..0000000000000 --- a/test/assets/playwrightweb.html +++ /dev/null @@ -1,12 +0,0 @@ - - \ No newline at end of file diff --git a/test/autowaiting.spec.js b/test/autowaiting.spec.js index 7e7725c980178..abe307347bf73 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.js index f5e032ef8ec0e..fbbd64dd26f36 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.js index d733fd53cb0d6..7e36459df4a77 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.js index e4cd4169f4a0a..c11c5d1cb012e 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.js index f8940ff88973c..75aa0fe145d92 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.js index 9b5a501ac3901..fa3b4aa6d2ae9 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.js index d5c81432ad2a6..c1472fc8203bc 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: false diff --git a/test/chromium/oopif.spec.js b/test/chromium/oopif.spec.js index 3e3c2c243a063..ef99e8269a7c7 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: false diff --git a/test/chromium/pdf.spec.js b/test/chromium/pdf.spec.js index 6ffde1d5f2eed..907288030a7de 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 headless describe.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.js index b9e1b5ca94412..6f41bc7624efe 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.js index 55075a25e08f5..dec98ef7bd1b4 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.js index efdff4f3f2312..af4e8d9cd6483 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.js index deeb4a529a016..69ecf331a7375 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.js index 7634a79e6a140..02c49cf11865e 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.js index 6a131cbc022ec..8765f5b144ae9 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.js index 1d4337de27076..fdd84b7e954f3 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.js index ae83bf9ff8ed9..0eaf5e31f4b19 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.js index 668d41852eb1c..ae04cf7fa9599 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.js index b77124cc53e9d..480f95ee79457 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.js index f360ba0f7d1dc..188774cb15f5a 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, pl handleSIGTERM: 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, pl describe('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.js index 34dc1d599d132..f1f3f2c422382 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.js index 1bb380233b1b1..41b36ab2d011c 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.js index 250a522e58c1c..8272755578ac4 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.js index 308f3c55df24d..b9241e6bc9d4a 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.js index 654ce4f878d34..17d4b9ffa2a06 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.js index f6270f4c10b9b..046157073db54 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: false diff --git a/test/ignorehttpserrors.spec.js b/test/ignorehttpserrors.spec.js index 8ba5b4c6b4c2c..8d8cd1b67ad5a 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, p const 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, p const 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.js index 5b5878f50b86f..d047d17a971b2 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.js index 6f35754bf3d93..f75c711ada984 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.js index eefb0f47f0c81..fd1c795ee60f9 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.js index ca45d3fe228c4..9d1e0e2d9cc74 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.js index b954e67b27de9..b17e2fa12aaa9 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.js index e9de98775868d..66c818d32a607 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.js index 7093e20849f03..58372f2670c75 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.js index 0d1f132ffa9b7..61592685d1477 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.js index a833f3d5af508..4187a144a6e94 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.js index 567742c8f588a..833afdc5ebd1c 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.js index 3aca18f22588a..2a96f8e5c7031 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.js index 5428fb272697d..f0cf61e1b36c5 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, playwright const 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, playwright WIN, 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, playwright return; 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.js index b158cc1dbbef3..ed680c731857c 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.js index e5ee9828f9018..14f2cee415980 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.js index e0059bfe4a44c..cd73e49b56f16 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.js index 2bf761782f8c5..2ccd61436b88d 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.js index f44e88a10ffa4..6efa9a0f52c7a 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.js index 9244838e48d54..f4aede4683250 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.js index 551c5cae4b649..91900e1d7efac 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}) {