chore(tests): add types for tests

This commit is contained in:
Joel Einbinder 2020-02-10 00:39:40 -08:00
parent 2dd11eaa09
commit 6cb6949d96
43 changed files with 132 additions and 6 deletions

View file

@ -15,6 +15,9 @@
* limitations under the License.
*/
/**
* @type {PageTestSuite}
*/
module.exports.describe = function({testRunner, expect, FFOX, CHROMIUM, WEBKIT, MAC}) {
const {describe, xdescribe, fdescribe} = testRunner;
const {it, fit, xit, dit} = testRunner;

View file

@ -16,6 +16,9 @@
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;

View file

@ -17,6 +17,9 @@
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;

View file

@ -17,6 +17,9 @@
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;

View file

@ -16,6 +16,9 @@
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;

View file

@ -14,6 +14,9 @@
* limitations under the License.
*/
/**
* @type {ChromiumTestSuite}
*/
module.exports.describe = function({testRunner, expect, FFOX, CHROMIUM, WEBKIT}) {
const {describe, xdescribe, fdescribe} = testRunner;
const {it, fit, xit, dit} = testRunner;

View file

@ -24,6 +24,9 @@ const mkdtempAsync = util.promisify(fs.mkdtemp);
const TMP_FOLDER = path.join(os.tmpdir(), 'pw_tmp_folder-');
/**
* @type {TestSuite}
*/
module.exports.describe = function({testRunner, expect, playwright, defaultBrowserOptions, FFOX, CHROMIUM, WEBKIT, WIN}) {
const {describe, xdescribe, fdescribe} = testRunner;
const {it, fit, xit, dit} = testRunner;

View file

@ -25,6 +25,9 @@ const statAsync = util.promisify(fs.stat);
const TMP_FOLDER = path.join(os.tmpdir(), 'pw_tmp_folder-');
/**
* @type {TestSuite}
*/
module.exports.describe = function({testRunner, expect, defaultBrowserOptions, playwright, WIN}) {
const {describe, xdescribe, fdescribe} = testRunner;
const {it, fit, xit, dit} = testRunner;

View file

@ -14,6 +14,9 @@
* limitations under the License.
*/
/**
* @type {ChromiumTestSuite}
*/
module.exports.describe = function({testRunner, expect, defaultBrowserOptions, playwright, FFOX, CHROMIUM, WEBKIT}) {
const {describe, xdescribe, fdescribe} = testRunner;
const {it, fit, xit, dit} = testRunner;

View file

@ -17,6 +17,9 @@
const fs = require('fs');
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;

View file

@ -16,6 +16,9 @@
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;

View file

@ -17,6 +17,9 @@
const fs = require('fs');
const path = require('path');
/**
* @type {ChromiumTestSuite}
*/
module.exports.describe = function({testRunner, expect, defaultBrowserOptions, playwright, ASSETS_DIR}) {
const {describe, xdescribe, fdescribe} = testRunner;
const {it, fit, xit, dit} = testRunner;

View file

@ -17,6 +17,9 @@
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;

View file

@ -15,6 +15,9 @@
* limitations under the License.
*/
/**
* @type {PageTestSuite}
*/
module.exports.describe = function({testRunner, expect, playwright, defaultBrowserOptions, MAC, FFOX, CHROMIUM, WEBKIT}) {
const {describe, xdescribe, fdescribe} = testRunner;
const {it, fit, xit, dit} = testRunner;

View file

@ -17,6 +17,9 @@
const { makeUserDataDir, removeUserDataDir } = require('./utils');
/**
* @type {PageTestSuite}
*/
module.exports.describe = function ({ testRunner, expect, defaultBrowserOptions, playwright }) {
const {describe, xdescribe, fdescribe} = testRunner;
const {it, fit, xit, dit} = testRunner;

View file

@ -15,6 +15,9 @@
* limitations under the License.
*/
/**
* @type {PageTestSuite}
*/
module.exports.describe = function({testRunner, expect, FFOX, CHROMIUM, WEBKIT}) {
const {describe, xdescribe, fdescribe} = testRunner;
const {it, fit, xit, dit} = testRunner;

View file

@ -17,6 +17,9 @@
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;

View file

@ -15,6 +15,9 @@
* limitations under the License.
*/
/**
* @type {PageTestSuite}
*/
module.exports.describe = function({testRunner, expect, playwright, FFOX, CHROMIUM, WEBKIT}) {
const {describe, xdescribe, fdescribe} = testRunner;
const {it, fit, xit, dit} = testRunner;

View file

@ -19,6 +19,9 @@ const utils = require('./utils');
const bigint = typeof BigInt !== 'undefined';
/**
* @type {PageTestSuite}
*/
module.exports.describe = function({testRunner, expect, FFOX, CHROMIUM, WEBKIT}) {
const {describe, xdescribe, fdescribe} = testRunner;
const {it, fit, xit, dit} = testRunner;

View file

@ -18,6 +18,9 @@
const fs = require('fs');
const path = require('path');
/**
* @type {PageTestSuite}
*/
module.exports.describe = function({testRunner, expect, WEBKIT}) {
const {describe, xdescribe, fdescribe} = testRunner;
const {it, fit, xit, dit} = testRunner;

View file

@ -18,6 +18,9 @@
const path = require('path');
const {spawn, execSync} = require('child_process');
/**
* @type {TestSuite}
*/
module.exports.describe = function({testRunner, expect, product, playwright, playwrightPath, defaultBrowserOptions, WIN, FFOX, CHROMIUM, WEBKIT}) {
const {describe, xdescribe, fdescribe} = testRunner;
const {it, fit, xit, dit} = testRunner;

View file

@ -17,6 +17,9 @@
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;

View file

@ -15,6 +15,9 @@
* limitations under the License.
*/
/**
* @type {PageTestSuite}
*/
module.exports.describe = function ({ testRunner, expect, FFOX, WEBKIT }) {
const {describe, xdescribe, fdescribe} = testRunner;
const {it, fit, xit, dit} = testRunner;

View file

@ -16,6 +16,9 @@
const { makeUserDataDir, removeUserDataDir } = require('./utils');
/**
* @type {TestSuite}
*/
module.exports.describe = function({testRunner, expect, playwright, defaultBrowserOptions, FFOX, CHROMIUM, WEBKIT, WIN}) {
const {describe, xdescribe, fdescribe} = testRunner;
const {it, fit, xit, dit} = testRunner;

View file

@ -15,6 +15,9 @@
* limitations under the License.
*/
/**
* @type {BrowserTestSuite}
*/
module.exports.describe = function({testRunner, expect, defaultBrowserOptions, playwright, FFOX, CHROMIUM, WEBKIT}) {
const {describe, xdescribe, fdescribe} = testRunner;
const {it, fit, xit, dit} = testRunner;

View file

@ -19,6 +19,9 @@ const path = require('path');
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;

View file

@ -20,6 +20,9 @@ const path = require('path');
const { helper } = require('../lib/helper');
const utils = require('./utils');
/**
* @type {PageTestSuite}
*/
module.exports.describe = function({testRunner, expect, defaultBrowserOptions, playwright, FFOX, CHROMIUM, WEBKIT}) {
const {describe, xdescribe, fdescribe} = testRunner;
const {it, fit, xit, dit} = testRunner;

View file

@ -15,6 +15,9 @@
* limitations under the License.
*/
/**
* @type {PageTestSuite}
*/
module.exports.describe = function({testRunner, expect, CHROMIUM, FFOX, WEBKIT}) {
const {describe, xdescribe, fdescribe} = testRunner;
const {it, fit, xit, dit} = testRunner;

View file

@ -18,6 +18,9 @@
const utils = require('./utils');
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;

View file

@ -20,6 +20,9 @@ const fs = require('fs');
const utils = require('./utils');
const { makeUserDataDir, removeUserDataDir } = require('./utils');
/**
* @type {TestSuite}
*/
module.exports.describe = function({testRunner, expect, defaultBrowserOptions, playwright, playwrightPath, product, CHROMIUM, FFOX, WEBKIT, WIN}) {
const {describe, xdescribe, fdescribe} = testRunner;
const {it, fit, xit, dit} = testRunner;
@ -42,7 +45,7 @@ module.exports.describe = function({testRunner, expect, defaultBrowserOptions, p
await playwright.launch(options).catch(e => waitError = e);
expect(waitError.message).toContain('Failed to launch');
});
if('should have default URL when launching browser', async function() {
it('should have default URL when launching browser', async function() {
const userDataDir = await makeUserDataDir();
const browserContext = await playwright.launchPersistent(userDataDir, defaultBrowserOptions);
const pages = (await browserContext.pages()).map(page => page.url());
@ -172,7 +175,7 @@ module.exports.describe = function({testRunner, expect, defaultBrowserOptions, p
});
describe('Browser.close', function() {
it('should terminate network waiters', async({context, server}) => {
it('should terminate network waiters', async({server}) => {
const browserServer = await playwright.launchServer({...defaultBrowserOptions });
const remote = await playwright.connect({ wsEndpoint: browserServer.wsEndpoint() });
const newPage = await remote.newPage();

View file

@ -26,6 +26,9 @@ 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;

View file

@ -17,6 +17,9 @@
const utils = require('./utils');
/**
* @type {TestSuite}
*/
module.exports.describe = function({testRunner, expect, defaultBrowserOptions, playwright, FFOX, CHROMIUM, WEBKIT}) {
const {describe, xdescribe, fdescribe} = testRunner;
const {it, fit, xit, dit} = testRunner;

View file

@ -18,6 +18,9 @@
const utils = require('./utils');
const { performance } = require('perf_hooks');
/**
* @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;

View file

@ -19,6 +19,9 @@ const fs = require('fs');
const path = require('path');
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;

View file

@ -19,6 +19,9 @@ const path = require('path');
const utils = require('./utils');
const {waitEvent} = utils;
/**
* @type {PageTestSuite}
*/
module.exports.describe = function({testRunner, expect, headless, playwright, FFOX, CHROMIUM, WEBKIT}) {
const {describe, xdescribe, fdescribe} = testRunner;
const {it, fit, xit, dit} = testRunner;

View file

@ -24,6 +24,9 @@ const {Matchers} = require('../utils/testrunner/');
const YELLOW_COLOR = '\x1b[33m';
const RESET_COLOR = '\x1b[0m';
/**
* @type {TestSuite}
*/
module.exports.describe = ({testRunner, product, playwrightPath}) => {
const {describe, xdescribe, fdescribe} = testRunner;
const {it, fit, xit, dit} = testRunner;

View file

@ -17,6 +17,9 @@
const zsSelectorEngineSource = require('../lib/generated/zsSelectorEngineSource');
/**
* @type {PageTestSuite}
*/
module.exports.describe = function({testRunner, expect, selectors, FFOX, CHROMIUM, WEBKIT}) {
const {describe, xdescribe, fdescribe} = testRunner;
const {it, fit, xit, dit} = testRunner;
@ -236,7 +239,7 @@ module.exports.describe = function({testRunner, expect, selectors, FFOX, CHROMIU
const element = await page.$$('//html/body/non-existing-element');
expect(element).toEqual([]);
});
it('should return multiple elements', async({page, sever}) => {
it('should return multiple elements', async({page, server}) => {
await page.setContent('<div></div><div></div>');
const elements = await page.$$('xpath=/html/body/div');
expect(elements.length).toBe(2);

View file

@ -15,6 +15,9 @@
* limitations under the License.
*/
/**
* @type {PageTestSuite}
*/
module.exports.describe = function({testRunner, expect, product, FFOX, CHROMIUM, WEBKIT}) {
const {describe, xdescribe, fdescribe} = testRunner;
const {it, fit, xit, dit} = testRunner;

View file

@ -17,6 +17,9 @@
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;

View file

@ -14,6 +14,9 @@
* limitations under the License.
*/
/**
* @type {PageTestSuite}
*/
module.exports.describe = function({testRunner, expect, defaultBrowserOptions, playwright, product, CHROMIUM, FFOX}) {
const {describe, xdescribe, fdescribe} = testRunner;
const {it, fit, xit, dit} = testRunner;

View file

@ -14,6 +14,9 @@
* limitations under the License.
*/
/**
* @type {PageTestSuite}
*/
module.exports.describe = function ({ testRunner, expect }) {
const {describe, xdescribe, fdescribe} = testRunner;
const {it, fit, xit, dit} = testRunner;

View file

@ -18,6 +18,9 @@
const utils = require('./utils');
const { waitEvent } = utils;
/**
* @type {PageTestSuite}
*/
module.exports.describe = function({testRunner, expect, FFOX, CHROMIUM, WEBKIT}) {
const {describe, xdescribe, fdescribe} = testRunner;
const {it, fit, xit, dit} = testRunner;

View file

@ -29,7 +29,7 @@ class TestServer {
/**
* @param {string} dirPath
* @param {number} port
* @return {!TestServer}
* @return {!Promise<TestServer>}
*/
static async create(dirPath, port) {
const server = new TestServer(dirPath, port);
@ -40,7 +40,7 @@ class TestServer {
/**
* @param {string} dirPath
* @param {number} port
* @return {!TestServer}
* @return {!Promise<TestServer>}
*/
static async createHTTPS(dirPath, port) {
const server = new TestServer(dirPath, port, {
@ -71,7 +71,7 @@ class TestServer {
this._startTime = new Date();
this._cachedPathPrefix = null;
/** @type {!Set<!net.Socket>} */
/** @type {!Set<!NodeJS.Socket>} */
this._sockets = new Set();
/** @type {!Map<string, function(!IncomingMessage, !ServerResponse)>} */