diff --git a/test/accessibility.spec.js b/test/accessibility.spec.js index 64ab278d4a..902e8c06ff 100644 --- a/test/accessibility.spec.js +++ b/test/accessibility.spec.js @@ -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; diff --git a/test/browser.spec.js b/test/browser.spec.js index 59421ed2ce..4232dce3a8 100644 --- a/test/browser.spec.js +++ b/test/browser.spec.js @@ -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; diff --git a/test/browsercontext.spec.js b/test/browsercontext.spec.js index 8e25831e03..6dc1e8a326 100644 --- a/test/browsercontext.spec.js +++ b/test/browsercontext.spec.js @@ -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; diff --git a/test/capabilities.spec.js b/test/capabilities.spec.js index 65c6fff14f..09bb059613 100644 --- a/test/capabilities.spec.js +++ b/test/capabilities.spec.js @@ -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; diff --git a/test/chromium/chromium.spec.js b/test/chromium/chromium.spec.js index 6307bf9e1e..5f106e9e1f 100644 --- a/test/chromium/chromium.spec.js +++ b/test/chromium/chromium.spec.js @@ -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; diff --git a/test/chromium/coverage.spec.js b/test/chromium/coverage.spec.js index 45a49009ca..8c99a50e20 100644 --- a/test/chromium/coverage.spec.js +++ b/test/chromium/coverage.spec.js @@ -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; diff --git a/test/chromium/headful.spec.js b/test/chromium/headful.spec.js index b2b3fc9da5..a1744665f5 100644 --- a/test/chromium/headful.spec.js +++ b/test/chromium/headful.spec.js @@ -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; diff --git a/test/chromium/launcher.spec.js b/test/chromium/launcher.spec.js index 8335157f48..0c96e30090 100644 --- a/test/chromium/launcher.spec.js +++ b/test/chromium/launcher.spec.js @@ -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; diff --git a/test/chromium/oopif.spec.js b/test/chromium/oopif.spec.js index 707d17c111..71f66bff40 100644 --- a/test/chromium/oopif.spec.js +++ b/test/chromium/oopif.spec.js @@ -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; diff --git a/test/chromium/pdf.spec.js b/test/chromium/pdf.spec.js index a6f3a0f071..64df44a300 100644 --- a/test/chromium/pdf.spec.js +++ b/test/chromium/pdf.spec.js @@ -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; diff --git a/test/chromium/session.spec.js b/test/chromium/session.spec.js index 8c6ddf82bb..163e30432c 100644 --- a/test/chromium/session.spec.js +++ b/test/chromium/session.spec.js @@ -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; diff --git a/test/chromium/tracing.spec.js b/test/chromium/tracing.spec.js index fea16eb9e3..fc9c16309e 100644 --- a/test/chromium/tracing.spec.js +++ b/test/chromium/tracing.spec.js @@ -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; diff --git a/test/click.spec.js b/test/click.spec.js index 07e7a9e0f4..f60f5ac365 100644 --- a/test/click.spec.js +++ b/test/click.spec.js @@ -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; diff --git a/test/cookies.spec.js b/test/cookies.spec.js index e06cdde358..767c122c8f 100644 --- a/test/cookies.spec.js +++ b/test/cookies.spec.js @@ -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; diff --git a/test/defaultbrowsercontext.spec.js b/test/defaultbrowsercontext.spec.js index 1d74f22ff3..a3100883ef 100644 --- a/test/defaultbrowsercontext.spec.js +++ b/test/defaultbrowsercontext.spec.js @@ -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; diff --git a/test/dialog.spec.js b/test/dialog.spec.js index 183169f5c1..6a131cbc02 100644 --- a/test/dialog.spec.js +++ b/test/dialog.spec.js @@ -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; diff --git a/test/elementhandle.spec.js b/test/elementhandle.spec.js index a4aaf1a40a..65620ba44e 100644 --- a/test/elementhandle.spec.js +++ b/test/elementhandle.spec.js @@ -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; diff --git a/test/emulation.spec.js b/test/emulation.spec.js index 2e849252d8..468b713faf 100644 --- a/test/emulation.spec.js +++ b/test/emulation.spec.js @@ -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; diff --git a/test/evaluation.spec.js b/test/evaluation.spec.js index 47a4a37ecb..7f2cf1bf22 100644 --- a/test/evaluation.spec.js +++ b/test/evaluation.spec.js @@ -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; diff --git a/test/features/permissions.spec.js b/test/features/permissions.spec.js index 56640dd6a1..ea531eeda5 100644 --- a/test/features/permissions.spec.js +++ b/test/features/permissions.spec.js @@ -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; diff --git a/test/fixtures.spec.js b/test/fixtures.spec.js index 1f9cf1eafd..95da9e2ef6 100644 --- a/test/fixtures.spec.js +++ b/test/fixtures.spec.js @@ -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; diff --git a/test/frame.spec.js b/test/frame.spec.js index 6cb912ba81..308f3c55df 100644 --- a/test/frame.spec.js +++ b/test/frame.spec.js @@ -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; diff --git a/test/geolocation.spec.js b/test/geolocation.spec.js index 5af6dbe521..4e0a30ec93 100644 --- a/test/geolocation.spec.js +++ b/test/geolocation.spec.js @@ -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; diff --git a/test/headful.spec.js b/test/headful.spec.js index 9bbc9c1f13..90b0ac12d9 100644 --- a/test/headful.spec.js +++ b/test/headful.spec.js @@ -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; diff --git a/test/ignorehttpserrors.spec.js b/test/ignorehttpserrors.spec.js index b9b623b53f..b2457edf87 100644 --- a/test/ignorehttpserrors.spec.js +++ b/test/ignorehttpserrors.spec.js @@ -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; diff --git a/test/input.spec.js b/test/input.spec.js index 1e3e6254fd..ea796842bd 100644 --- a/test/input.spec.js +++ b/test/input.spec.js @@ -21,6 +21,9 @@ const formidable = require('formidable'); 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; diff --git a/test/interception.spec.js b/test/interception.spec.js index 4922806bc2..003996ef8d 100644 --- a/test/interception.spec.js +++ b/test/interception.spec.js @@ -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; diff --git a/test/jshandle.spec.js b/test/jshandle.spec.js index 270079c1c1..69b72e442d 100644 --- a/test/jshandle.spec.js +++ b/test/jshandle.spec.js @@ -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; diff --git a/test/keyboard.spec.js b/test/keyboard.spec.js index 0ade260ee6..d5bf294d15 100644 --- a/test/keyboard.spec.js +++ b/test/keyboard.spec.js @@ -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; diff --git a/test/launcher.spec.js b/test/launcher.spec.js index a68b91d772..f9e513133b 100644 --- a/test/launcher.spec.js +++ b/test/launcher.spec.js @@ -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(); diff --git a/test/mouse.spec.js b/test/mouse.spec.js index 9024d17757..de1ac8b3d3 100644 --- a/test/mouse.spec.js +++ b/test/mouse.spec.js @@ -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; diff --git a/test/multiclient.spec.js b/test/multiclient.spec.js index 46c53ae039..3f7ab0db61 100644 --- a/test/multiclient.spec.js +++ b/test/multiclient.spec.js @@ -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; diff --git a/test/navigation.spec.js b/test/navigation.spec.js index 126c3cfaf5..5e0d30c4f2 100644 --- a/test/navigation.spec.js +++ b/test/navigation.spec.js @@ -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; diff --git a/test/network.spec.js b/test/network.spec.js index cafa1490df..d5c915ae6c 100644 --- a/test/network.spec.js +++ b/test/network.spec.js @@ -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; diff --git a/test/page.spec.js b/test/page.spec.js index cfcfd8a5f9..e42d215218 100644 --- a/test/page.spec.js +++ b/test/page.spec.js @@ -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; diff --git a/test/playwright.spec.js b/test/playwright.spec.js index e761ec975e..38590dba63 100644 --- a/test/playwright.spec.js +++ b/test/playwright.spec.js @@ -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; diff --git a/test/queryselector.spec.js b/test/queryselector.spec.js index e84105c380..27161b4f69 100644 --- a/test/queryselector.spec.js +++ b/test/queryselector.spec.js @@ -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('
'); const elements = await page.$$('xpath=/html/body/div'); expect(elements.length).toBe(2); diff --git a/test/screenshot.spec.js b/test/screenshot.spec.js index 478c34380c..6b184ff236 100644 --- a/test/screenshot.spec.js +++ b/test/screenshot.spec.js @@ -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; diff --git a/test/tsconfig.json b/test/tsconfig.json new file mode 100644 index 0000000000..158060dd73 --- /dev/null +++ b/test/tsconfig.json @@ -0,0 +1,11 @@ +{ + "compilerOptions": { + "allowJs": true, + "checkJs": false, + "noEmit": true, + "moduleResolution": "node", + "target": "ESNext", + "strictNullChecks": false, + }, + "include": ["*.spec.js", "types.d.ts"] + } \ No newline at end of file diff --git a/test/types.d.ts b/test/types.d.ts new file mode 100644 index 0000000000..5aaa2ef67d --- /dev/null +++ b/test/types.d.ts @@ -0,0 +1,103 @@ +type ServerResponse = import('http').ServerResponse; +type IncomingMessage = import('http').IncomingMessage; + +type Falsy = false|""|0|null|undefined; +interface Expect