test: put test runner api on global, remove unused parameters (#1684)

This commit is contained in:
Dmitry Gozman 2020-04-07 08:10:31 -07:00 committed by GitHub
parent e15fc08d46
commit e0c8fbf1a6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
48 changed files with 70 additions and 236 deletions

View file

@ -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}) {

View file

@ -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>

View file

@ -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}) => {

View file

@ -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}) {

View file

@ -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}) {

View file

@ -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}) {

View file

@ -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}) => {

View file

@ -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}) {

View file

@ -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

View file

@ -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

View file

@ -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);

View file

@ -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}) {

View file

@ -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();
});

View file

@ -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}) => {

View file

@ -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}) => {

View file

@ -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 => {

View file

@ -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}) => {

View file

@ -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) => {

View file

@ -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}) => {

View file

@ -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'];

View file

@ -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}) => {

View file

@ -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');

View file

@ -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)

View file

@ -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) {
}

View file

@ -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}) {

View file

@ -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}) => {

View file

@ -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}) => {

View file

@ -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

View file

@ -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}) => {

View file

@ -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');

View file

@ -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}) => {

View file

@ -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}) => {

View file

@ -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}) => {

View file

@ -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() {

View file

@ -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}) => {

View file

@ -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 () => {

View file

@ -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}) => {

View file

@ -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}) => {

View file

@ -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}) => {

View file

@ -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() {

View file

@ -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);
}
});
}

View file

@ -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}) {

View file

@ -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}) => {

View file

@ -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}) => {

View file

@ -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; });

View file

@ -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()) {

View file

@ -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}) => {

View file

@ -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}) {