Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Apr 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions test/accessibility.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}) {
Expand Down
12 changes: 0 additions & 12 deletions test/assets/playwrightweb.html

This file was deleted.

5 changes: 1 addition & 4 deletions test/autowaiting.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}) => {
Expand Down
7 changes: 1 addition & 6 deletions test/browser.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}) {
Expand Down
5 changes: 1 addition & 4 deletions test/browsercontext.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}) {
Expand Down
8 changes: 1 addition & 7 deletions test/capabilities.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}) {
Expand Down
7 changes: 1 addition & 6 deletions test/chromium/chromium.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}) => {
Expand Down
5 changes: 1 addition & 4 deletions test/chromium/coverage.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}) {
Expand Down
11 changes: 1 addition & 10 deletions test/chromium/launcher.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 1 addition & 4 deletions test/chromium/oopif.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 2 additions & 5 deletions test/chromium/pdf.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 1 addition & 4 deletions test/chromium/session.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}) {
Expand Down
7 changes: 2 additions & 5 deletions test/chromium/tracing.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
Expand Down
5 changes: 1 addition & 4 deletions test/click.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}) => {
Expand Down
5 changes: 1 addition & 4 deletions test/cookies.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}) => {
Expand Down
5 changes: 1 addition & 4 deletions test/defaultbrowsercontext.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down
5 changes: 1 addition & 4 deletions test/dialog.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}) => {
Expand Down
5 changes: 1 addition & 4 deletions test/download.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
5 changes: 1 addition & 4 deletions test/elementhandle.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}) => {
Expand Down
5 changes: 1 addition & 4 deletions test/emulation.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@
/**
* @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'];

Expand Down
6 changes: 1 addition & 5 deletions test/evaluation.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}) => {
Expand Down
16 changes: 3 additions & 13 deletions test/fixtures.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand All @@ -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 = '';
Expand Down Expand Up @@ -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');
Expand Down
4 changes: 2 additions & 2 deletions test/fixtures/closeme.js
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
5 changes: 2 additions & 3 deletions test/fixtures/dumpio.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,16 @@
console.log('unhandledRejection', error.message);
});

const [, , playwrightRoot, product, useWebSocket] = process.argv;
const [, , playwrightRoot, browserType] = process.argv;
const options = {
ignoreDefaultArgs: true,
dumpio: true,
timeout: 1,
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) {
}
Expand Down
8 changes: 1 addition & 7 deletions test/focus.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}) {
Expand Down
5 changes: 1 addition & 4 deletions test/frame.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}) => {
Expand Down
Loading