From 2f5a0a6c07f9dd94aee3ab661a3841a91816d2f4 Mon Sep 17 00:00:00 2001 From: Pavel Feldman Date: Fri, 14 Aug 2020 07:22:54 -0700 Subject: [PATCH] test: slowly removing testOptions (#3464) --- docs/test-runners.md | 2 + test/accessibility.spec.ts | 2 - test/autowaiting-basic.spec.ts | 5 +-- test/autowaiting-no-hang.spec.ts | 2 - test/base.fixture.ts | 10 ++++- test/browser.spec.ts | 1 - test/browsercontext-add-cookies.spec.ts | 3 -- test/browsercontext-basic.spec.ts | 2 - test/browsercontext-cookies.spec.ts | 3 -- test/browsercontext-credentials.spec.ts | 3 +- test/browsercontext-device.spec.ts | 3 -- test/browsercontext-expose-function.spec.ts | 4 -- test/browsercontext-locale.spec.ts | 3 -- test/browsercontext-page-event.spec.ts | 3 -- test/browsercontext-route.spec.ts | 4 -- test/browsercontext-timezone-id.spec.ts | 3 -- test/browsercontext-user-agent.spec.ts | 1 - test/browsercontext-viewport-mobile.spec.ts | 3 -- test/browsercontext-viewport.spec.ts | 1 - test/browsertype-basic.spec.ts | 5 +-- test/browsertype-connect.spec.ts | 3 +- test/browsertype-launch-server.spec.ts | 5 +-- test/browsertype-launch.spec.ts | 7 ++-- test/capabilities.spec.ts | 5 +-- test/channels.spec.ts | 3 -- test/chromium-css-coverage.spec.ts | 3 -- test/chromium-js-coverage.spec.ts | 3 -- test/chromium/chromium.spec.ts | 2 - test/chromium/launcher.spec.ts | 4 +- test/chromium/oopif.spec.ts | 2 - test/chromium/session.spec.ts | 2 - test/chromium/tracing.spec.ts | 3 +- test/click-react.spec.ts | 1 - test/click-timeout-1.spec.ts | 3 +- test/click-timeout-2.spec.ts | 3 -- test/click-timeout-3.spec.ts | 3 +- test/click-timeout-4.spec.ts | 1 - test/click.spec.ts | 4 +- test/defaultbrowsercontext.spec.ts | 43 ++++++++------------- test/dialog.spec.ts | 10 ++--- test/dispatchevent.spec.ts | 3 +- test/download.spec.ts | 2 +- test/downloads-path.spec.ts | 28 ++++++-------- test/electron/electron-app.spec.ts | 2 - test/electron/electron-window.spec.ts | 2 - test/elementhandle-bounding-box.spec.ts | 3 +- test/elementhandle-click.spec.ts | 3 -- test/elementhandle-content-frame.spec.ts | 1 - test/elementhandle-convenience.spec.ts | 1 - test/elementhandle-eval-on-selector.spec.ts | 4 -- test/elementhandle-misc.spec.ts | 3 -- test/elementhandle-owner-frame.spec.ts | 1 - test/elementhandle-press.spec.ts | 3 -- test/elementhandle-query-selector.spec.ts | 4 -- test/elementhandle-screenshot.spec.ts | 2 +- test/elementhandle-scroll-into-view.spec.ts | 3 -- test/elementhandle-select-text.spec.ts | 3 -- test/elementhandle-type.spec.ts | 3 -- test/emulation-focus.spec.ts | 2 +- test/eval-on-selector-all.spec.ts | 4 -- test/eval-on-selector.spec.ts | 4 -- test/firefox/launcher.spec.ts | 2 - test/fixtures.spec.ts | 2 +- test/focus.spec.ts | 2 - test/frame-evaluate.spec.ts | 3 +- test/frame-frame-element.spec.ts | 1 - test/frame-goto.spec.ts | 3 -- test/frame-hierarchy.spec.ts | 1 - test/geolocation.spec.ts | 2 - test/headful.spec.ts | 15 +++---- test/ignorehttpserrors.spec.ts | 2 - test/interception.spec.ts | 3 -- test/jshandle-as-element.spec.ts | 10 ++--- test/jshandle-evaluate.spec.ts | 6 +-- test/jshandle-json-value.spec.ts | 8 ++-- test/jshandle-properties.spec.ts | 14 +++---- test/jshandle-to-string.spec.ts | 10 ++--- test/keyboard.spec.ts | 4 +- test/launcher.spec.ts | 4 +- test/logger.spec.ts | 4 -- test/mouse.spec.ts | 2 - test/multiclient.spec.ts | 2 +- test/network-request.spec.ts | 3 -- test/network-response.spec.ts | 2 - test/page-add-init-script.spec.ts | 2 - test/page-add-script-tag.spec.ts | 3 -- test/page-add-style-tag.spec.ts | 3 -- test/page-basic.spec.ts | 5 --- test/page-emulate-media.spec.ts | 1 - test/page-evaluate-handle.spec.ts | 2 - test/page-evaluate.spec.ts | 3 +- test/page-event-console.spec.ts | 3 -- test/page-event-crash.spec.ts | 5 +-- test/page-event-network.spec.ts | 5 --- test/page-event-pageerror.spec.ts | 3 -- test/page-event-popup.spec.ts | 2 - test/page-event-request.spec.ts | 3 -- test/page-expose-function.spec.ts | 5 --- test/page-fill.spec.ts | 5 --- test/page-goto.spec.ts | 1 - test/page-history.spec.ts | 2 - test/page-network-idle.spec.ts | 4 -- test/page-route.spec.ts | 6 --- test/page-screenshot.spec.ts | 3 +- test/page-select-option.spec.ts | 5 --- test/page-set-content.spec.ts | 6 +-- test/page-set-extra-http-headers.spec.ts | 6 --- test/page-wait-for-load-state.spec.ts | 4 -- test/page-wait-for-navigation.spec.ts | 4 -- test/page-wait-for-request.spec.ts | 3 -- test/page-wait-for-response.spec.ts | 5 --- test/pdf.spec.ts | 2 +- test/permissions.spec.ts | 3 +- test/popup.spec.ts | 3 -- test/proxy.spec.ts | 4 +- test/queryselector.spec.ts | 4 -- test/request-continue.spec.ts | 6 --- test/request-fulfill.spec.ts | 5 +-- test/runner/testOptions.js | 10 ----- test/screencast.spec.ts | 8 ++-- test/selectors-css.spec.ts | 4 -- test/selectors-misc.spec.ts | 4 -- test/selectors-register.spec.ts | 1 - test/selectors-text.spec.ts | 4 -- test/types.d.ts | 15 +++---- test/wait-for-function.spec.ts | 29 +++++++------- test/wait-for-selector.spec.ts | 4 +- test/workers.spec.ts | 3 +- 128 files changed, 130 insertions(+), 437 deletions(-) diff --git a/docs/test-runners.md b/docs/test-runners.md index 2448a4f69c..e6e5c0608c 100644 --- a/docs/test-runners.md +++ b/docs/test-runners.md @@ -34,6 +34,7 @@ beforeEach(async () => { afterEach(async () => { await page.close(); }); + it('should work', async () => { await page.goto('https://www.example.com/'); expect(await page.title()).toBe('Example Domain'); @@ -90,6 +91,7 @@ beforeEach(async() => { afterEach(async () => { await page.close(); }); + it('should work', async () => { await page.goto('https://www.example.com/'); assert.equal(await page.title(), 'Example Domain'); diff --git a/test/accessibility.spec.ts b/test/accessibility.spec.ts index 6e8a3ff316..c9a464edf0 100644 --- a/test/accessibility.spec.ts +++ b/test/accessibility.spec.ts @@ -16,8 +16,6 @@ */ import './base.fixture'; -const {FFOX, CHROMIUM, WEBKIT} = testOptions; - it('should work', async function({page}) { await page.setContent(` diff --git a/test/autowaiting-basic.spec.ts b/test/autowaiting-basic.spec.ts index d8cee0d6c6..5a9cb7619f 100644 --- a/test/autowaiting-basic.spec.ts +++ b/test/autowaiting-basic.spec.ts @@ -15,10 +15,7 @@ * limitations under the License. */ import './base.fixture'; - -import utils from './utils'; - -const {WIRE} = testOptions; +const { WIRE } = testOptions; it('should await navigation when clicking anchor', async({page, server}) => { const messages = []; diff --git a/test/autowaiting-no-hang.spec.ts b/test/autowaiting-no-hang.spec.ts index a69f1ba839..43da0fd210 100644 --- a/test/autowaiting-no-hang.spec.ts +++ b/test/autowaiting-no-hang.spec.ts @@ -16,8 +16,6 @@ */ import './base.fixture'; -import utils from './utils'; - it('clicking on links which do not commit navigation', async({page, server, httpsServer}) => { await page.goto(server.EMPTY_PAGE); await page.setContent(`foobar`); diff --git a/test/base.fixture.ts b/test/base.fixture.ts index 6953552f5f..dfe20f54ad 100644 --- a/test/base.fixture.ts +++ b/test/base.fixture.ts @@ -32,6 +32,7 @@ import {mkdtempAsync, removeFolderAsync} from './utils'; setUnderTest(); // Note: we must call setUnderTest before requiring Playwright const browserName = process.env.BROWSER || 'chromium'; +const platform = os.platform(); declare global { interface WorkerState { @@ -54,6 +55,13 @@ declare global { } } +(global as any).MAC = platform === 'darwin'; +(global as any).LINUX = platform === 'linux'; +(global as any).WIN = platform === 'win32'; +(global as any).CHROMIUM = browserName === 'chromium'; +(global as any).FFOX = browserName === 'firefox'; +(global as any).WEBKIT = browserName === 'webkit'; + registerWorkerFixture('parallelIndex', async ({}, test) => { await test(parseInt(process.env.JEST_WORKER_ID, 10) - 1); }); @@ -180,7 +188,7 @@ registerFixture('httpsServer', async ({httpService}, test) => { registerFixture('tmpDir', async ({}, test) => { const tmpDir = await mkdtempAsync(path.join(os.tmpdir(), 'playwright-test-')); await test(tmpDir); - await removeFolderAsync(tmpDir); + await removeFolderAsync(tmpDir).catch(e => {}); }); registerWorkerFixture('asset', async ({}, test) => { diff --git a/test/browser.spec.ts b/test/browser.spec.ts index 07feadfd6a..239a7b252a 100644 --- a/test/browser.spec.ts +++ b/test/browser.spec.ts @@ -16,7 +16,6 @@ import './base.fixture'; import utils from './utils'; -const {CHROMIUM} = testOptions; it('should create new page', async function({browser}) { const page1 = await browser.newPage(); diff --git a/test/browsercontext-add-cookies.spec.ts b/test/browsercontext-add-cookies.spec.ts index c48fc6d083..a8dae35607 100644 --- a/test/browsercontext-add-cookies.spec.ts +++ b/test/browsercontext-add-cookies.spec.ts @@ -16,9 +16,6 @@ */ import './base.fixture'; -import utils from './utils'; -const {FFOX, CHROMIUM} = testOptions; - it('should work', async({context, page, server}) => { await page.goto(server.EMPTY_PAGE); await context.addCookies([{ diff --git a/test/browsercontext-basic.spec.ts b/test/browsercontext-basic.spec.ts index ad98ee17fd..5acb9abcdd 100644 --- a/test/browsercontext-basic.spec.ts +++ b/test/browsercontext-basic.spec.ts @@ -18,8 +18,6 @@ import './base.fixture'; import utils from './utils'; -const {WEBKIT} = testOptions; - it('should create new context', async function({browser}) { expect(browser.contexts().length).toBe(0); const context = await browser.newContext(); diff --git a/test/browsercontext-cookies.spec.ts b/test/browsercontext-cookies.spec.ts index 76f809f34a..94308a0289 100644 --- a/test/browsercontext-cookies.spec.ts +++ b/test/browsercontext-cookies.spec.ts @@ -16,9 +16,6 @@ */ import './base.fixture'; -import utils from './utils'; -const {FFOX, WEBKIT, WIN} = testOptions; - it('should return no cookies in pristine browser context', async({context, page, server}) => { expect(await context.cookies()).toEqual([]); }); diff --git a/test/browsercontext-credentials.spec.ts b/test/browsercontext-credentials.spec.ts index 43ce9f23eb..53f648ad14 100644 --- a/test/browsercontext-credentials.spec.ts +++ b/test/browsercontext-credentials.spec.ts @@ -16,8 +16,7 @@ */ import './base.fixture'; -import utils from './utils'; -const {CHROMIUM, HEADLESS} = testOptions; +const { HEADLESS } = testOptions; it.fail(CHROMIUM && !HEADLESS)('should fail without credentials', async({browser, server}) => { server.setAuth('/empty.html', 'user', 'pass'); diff --git a/test/browsercontext-device.spec.ts b/test/browsercontext-device.spec.ts index 259747d02e..e448d8a92b 100644 --- a/test/browsercontext-device.spec.ts +++ b/test/browsercontext-device.spec.ts @@ -16,9 +16,6 @@ */ import './base.fixture'; -import utils from './utils'; -const {FFOX} = testOptions; - it.skip(FFOX)('should work', async({playwright, browser, server}) => { const iPhone = playwright.devices['iPhone 6']; const context = await browser.newContext({ ...iPhone }); diff --git a/test/browsercontext-expose-function.spec.ts b/test/browsercontext-expose-function.spec.ts index 415197cb87..185c835a27 100644 --- a/test/browsercontext-expose-function.spec.ts +++ b/test/browsercontext-expose-function.spec.ts @@ -16,10 +16,6 @@ */ import './base.fixture'; -import utils from './utils'; -const {FFOX, CHROMIUM, WEBKIT, MAC, HEADLESS} = testOptions; -const {devices} = require('..'); - it('expose binding should work', async({browser}) => { const context = await browser.newContext(); let bindingSource; diff --git a/test/browsercontext-locale.spec.ts b/test/browsercontext-locale.spec.ts index c51421df55..f37ed462c6 100644 --- a/test/browsercontext-locale.spec.ts +++ b/test/browsercontext-locale.spec.ts @@ -16,9 +16,6 @@ */ import './base.fixture'; -import utils from './utils'; -const {CHROMIUM, FFOX, MAC, HEADLESS} = testOptions; - it('should affect accept-language header', async({browser, server}) => { const context = await browser.newContext({ locale: 'fr-CH' }); const page = await context.newPage(); diff --git a/test/browsercontext-page-event.spec.ts b/test/browsercontext-page-event.spec.ts index ac4cfcb388..09ad98763a 100644 --- a/test/browsercontext-page-event.spec.ts +++ b/test/browsercontext-page-event.spec.ts @@ -15,9 +15,6 @@ * limitations under the License. */ import './base.fixture'; -import utils from './utils'; -const {FFOX, CHROMIUM, WEBKIT, MAC, HEADLESS} = testOptions; -const {devices} = require('..'); it('should have url', async({browser, server}) => { const context = await browser.newContext(); diff --git a/test/browsercontext-route.spec.ts b/test/browsercontext-route.spec.ts index 5f1adec3bb..f21471c685 100644 --- a/test/browsercontext-route.spec.ts +++ b/test/browsercontext-route.spec.ts @@ -16,10 +16,6 @@ */ import './base.fixture'; -import utils from './utils'; -const {FFOX, CHROMIUM, WEBKIT, MAC, HEADLESS} = testOptions; -const {devices} = require('..'); - it('should intercept', async({browser, server}) => { const context = await browser.newContext(); let intercepted = false; diff --git a/test/browsercontext-timezone-id.spec.ts b/test/browsercontext-timezone-id.spec.ts index bc51ada3ec..d377408860 100644 --- a/test/browsercontext-timezone-id.spec.ts +++ b/test/browsercontext-timezone-id.spec.ts @@ -16,9 +16,6 @@ */ import './base.fixture'; -import utils from './utils'; -const {CHROMIUM, FFOX, MAC, HEADLESS} = testOptions; - it('should work', async ({ browser }) => { const func = () => new Date(1479579154987).toString(); { diff --git a/test/browsercontext-user-agent.spec.ts b/test/browsercontext-user-agent.spec.ts index 27e4a9920a..5d003c124c 100644 --- a/test/browsercontext-user-agent.spec.ts +++ b/test/browsercontext-user-agent.spec.ts @@ -17,7 +17,6 @@ import './base.fixture'; import utils from './utils'; -const {FFOX, CHROMIUM, WEBKIT, MAC, HEADLESS} = testOptions; const {devices} = require('..'); it('should work', async({browser, server}) => { diff --git a/test/browsercontext-viewport-mobile.spec.ts b/test/browsercontext-viewport-mobile.spec.ts index 6ea3801ba8..f364a8f984 100644 --- a/test/browsercontext-viewport-mobile.spec.ts +++ b/test/browsercontext-viewport-mobile.spec.ts @@ -16,9 +16,6 @@ */ import './base.fixture'; -import utils from './utils'; -const {CHROMIUM, FFOX, MAC, HEADLESS} = testOptions; - it.skip(FFOX)('should support mobile emulation', async({playwright, browser, server}) => { const iPhone = playwright.devices['iPhone 6']; const context = await browser.newContext({ ...iPhone }); diff --git a/test/browsercontext-viewport.spec.ts b/test/browsercontext-viewport.spec.ts index dc71f3790a..676a277ef2 100644 --- a/test/browsercontext-viewport.spec.ts +++ b/test/browsercontext-viewport.spec.ts @@ -17,7 +17,6 @@ import './base.fixture'; import utils from './utils'; -const {CHROMIUM, FFOX, MAC, HEADLESS} = testOptions; it('should get the proper default viewport size', async({page, server}) => { await utils.verifyViewport(page, 1280, 720); diff --git a/test/browsertype-basic.spec.ts b/test/browsertype-basic.spec.ts index 5a9c9bcf2c..d4bdaa2a15 100644 --- a/test/browsertype-basic.spec.ts +++ b/test/browsertype-basic.spec.ts @@ -14,12 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import './base.fixture'; -import path from 'path'; import fs from 'fs'; -import utils from './utils'; -const {FFOX, CHROMIUM, WEBKIT, WIN, WIRE} = testOptions; +import './base.fixture'; it('browserType.executablePath should work', async({browserType}) => { const executablePath = browserType.executablePath(); diff --git a/test/browsertype-connect.spec.ts b/test/browsertype-connect.spec.ts index db38653af1..a861f7bc13 100644 --- a/test/browsertype-connect.spec.ts +++ b/test/browsertype-connect.spec.ts @@ -16,8 +16,7 @@ */ import './base.fixture'; -import utils from './utils'; -const {FFOX, CHROMIUM, WEBKIT, WIN, WIRE} = testOptions; +const { WIRE } = testOptions; it.skip(WIRE).slow()('should be able to reconnect to a browser', async({browserType, defaultBrowserOptions, server}) => { const browserServer = await browserType.launchServer(defaultBrowserOptions); diff --git a/test/browsertype-launch-server.spec.ts b/test/browsertype-launch-server.spec.ts index ebc673012f..9758de565b 100644 --- a/test/browsertype-launch-server.spec.ts +++ b/test/browsertype-launch-server.spec.ts @@ -16,10 +16,7 @@ */ import './base.fixture'; -import path from 'path'; -import fs from 'fs'; -import utils from './utils'; -const {FFOX, CHROMIUM, WEBKIT, WIN, WIRE} = testOptions; +const { WIRE } = testOptions; it.skip(WIRE)('should work', async({browserType, defaultBrowserOptions}) => { const browserServer = await browserType.launchServer(defaultBrowserOptions); diff --git a/test/browsertype-launch.spec.ts b/test/browsertype-launch.spec.ts index 50188cc372..5fceee5eed 100644 --- a/test/browsertype-launch.spec.ts +++ b/test/browsertype-launch.spec.ts @@ -14,12 +14,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import './base.fixture'; import path from 'path'; -import fs from 'fs'; -import utils from './utils'; -const {FFOX, CHROMIUM, WEBKIT, WIN, WIRE} = testOptions; +import './base.fixture'; + +const { WIRE } = testOptions; it('should reject all promises when browser is closed', async({browserType, defaultBrowserOptions}) => { const browser = await browserType.launch(defaultBrowserOptions); diff --git a/test/capabilities.spec.ts b/test/capabilities.spec.ts index 6485665c49..916bdd9040 100644 --- a/test/capabilities.spec.ts +++ b/test/capabilities.spec.ts @@ -13,12 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import './base.fixture'; -import path from 'path'; import url from 'url'; - -const {FFOX, CHROMIUM, WEBKIT, WIN, LINUX} = testOptions; +import './base.fixture'; it.fail(WEBKIT && WIN)('Web Assembly should work', async function({page, server}) { await page.goto(server.PREFIX + '/wasm/table2.html'); diff --git a/test/channels.spec.ts b/test/channels.spec.ts index 05b936ca6d..e7a620ee6b 100644 --- a/test/channels.spec.ts +++ b/test/channels.spec.ts @@ -15,10 +15,7 @@ * limitations under the License. */ import './base.fixture'; - -import utils from './utils'; import { ChromiumBrowser } from '..'; -const { FFOX, CHROMIUM, WEBKIT, WIN } = testOptions; it('should work', async({browser}) => { expect(!!browser['_connection']).toBeTruthy(); diff --git a/test/chromium-css-coverage.spec.ts b/test/chromium-css-coverage.spec.ts index 7cb3e8ef36..64c0b302dc 100644 --- a/test/chromium-css-coverage.spec.ts +++ b/test/chromium-css-coverage.spec.ts @@ -15,9 +15,6 @@ */ import './base.fixture'; -import utils from './utils'; -const {FFOX, CHROMIUM, WEBKIT} = testOptions; - it.skip(!CHROMIUM)('should work', async function({browserType, page, server}) { await page.coverage.startCSSCoverage(); await page.goto(server.PREFIX + '/csscoverage/simple.html'); diff --git a/test/chromium-js-coverage.spec.ts b/test/chromium-js-coverage.spec.ts index cfc34f5edc..49fed712f7 100644 --- a/test/chromium-js-coverage.spec.ts +++ b/test/chromium-js-coverage.spec.ts @@ -15,9 +15,6 @@ */ import './base.fixture'; -import utils from './utils'; -const {FFOX, CHROMIUM, WEBKIT} = testOptions; - it.skip(CHROMIUM)('should be missing', async function({page, server}) { expect(page.coverage).toBe(null); }); diff --git a/test/chromium/chromium.spec.ts b/test/chromium/chromium.spec.ts index 8828d9937e..29f1189392 100644 --- a/test/chromium/chromium.spec.ts +++ b/test/chromium/chromium.spec.ts @@ -16,8 +16,6 @@ import '../base.fixture'; import { ChromiumBrowserContext } from '../..'; -const {FFOX, CHROMIUM, WEBKIT} = testOptions; - it.skip(!CHROMIUM)('should create a worker from a service worker', async({page, server, context}) => { const [worker] = await Promise.all([ (context as ChromiumBrowserContext).waitForEvent('serviceworker'), diff --git a/test/chromium/launcher.spec.ts b/test/chromium/launcher.spec.ts index 89669bde60..6602fef667 100644 --- a/test/chromium/launcher.spec.ts +++ b/test/chromium/launcher.spec.ts @@ -18,8 +18,8 @@ import '../base.fixture'; import path from 'path'; import utils from '../utils'; import { ChromiumBrowser, ChromiumBrowserContext } from '../..'; -const {makeUserDataDir, removeUserDataDir} = utils; -const {FFOX, CHROMIUM, WEBKIT, WIN, WIRE} = testOptions; +const { makeUserDataDir, removeUserDataDir } = utils; +const { WIRE } = testOptions; it.skip(WIRE || !CHROMIUM)('should throw with remote-debugging-pipe argument', async({browserType, defaultBrowserOptions}) => { const options = Object.assign({}, defaultBrowserOptions); diff --git a/test/chromium/oopif.spec.ts b/test/chromium/oopif.spec.ts index 2f2e2b986f..d275b0c7b8 100644 --- a/test/chromium/oopif.spec.ts +++ b/test/chromium/oopif.spec.ts @@ -17,8 +17,6 @@ import '../base.fixture'; import { registerWorkerFixture } from '../runner/fixtures'; -const {CHROMIUM} = testOptions; - registerWorkerFixture('browser', async ({browserType, defaultBrowserOptions}, test) => { const browser = await browserType.launch({ ...defaultBrowserOptions, diff --git a/test/chromium/session.spec.ts b/test/chromium/session.spec.ts index 1329c6fc3e..fc62e310fd 100644 --- a/test/chromium/session.spec.ts +++ b/test/chromium/session.spec.ts @@ -16,8 +16,6 @@ import '../base.fixture'; import { ChromiumBrowserContext, ChromiumBrowser } from "../../types/types"; -const {FFOX, CHROMIUM, WEBKIT, WIRE} = testOptions; - it.skip(!CHROMIUM)('should work', async function({page}) { const client = await (page.context() as ChromiumBrowserContext).newCDPSession(page); diff --git a/test/chromium/tracing.spec.ts b/test/chromium/tracing.spec.ts index 1c0273c6e0..b58701f130 100644 --- a/test/chromium/tracing.spec.ts +++ b/test/chromium/tracing.spec.ts @@ -19,12 +19,13 @@ import { registerFixture } from '../runner/fixtures'; import fs from 'fs'; import path from 'path'; import { ChromiumBrowser } from '../..'; -const {FFOX, CHROMIUM, WEBKIT} = testOptions; + declare global { interface FixtureState { outputFile: string; } } + registerFixture('outputFile', async ({tmpDir}, test) => { const outputFile = path.join(tmpDir, `trace.json`); await test(outputFile); diff --git a/test/click-react.spec.ts b/test/click-react.spec.ts index b08bd55fb7..db6f0fb127 100644 --- a/test/click-react.spec.ts +++ b/test/click-react.spec.ts @@ -15,7 +15,6 @@ * limitations under the License. */ import './base.fixture'; -import utils from './utils'; declare const renderComponent; declare const e; diff --git a/test/click-timeout-1.spec.ts b/test/click-timeout-1.spec.ts index 96b6e5ab9c..1a6ed6ee9c 100644 --- a/test/click-timeout-1.spec.ts +++ b/test/click-timeout-1.spec.ts @@ -16,8 +16,7 @@ */ import './base.fixture'; -import utils from './utils'; -const {WIRE} = testOptions; +const { WIRE } = testOptions; it.skip(WIRE)('should avoid side effects after timeout', async({page, server}) => { await page.goto(server.PREFIX + '/input/button.html'); diff --git a/test/click-timeout-2.spec.ts b/test/click-timeout-2.spec.ts index 8b42833cd2..6c0ebe361f 100644 --- a/test/click-timeout-2.spec.ts +++ b/test/click-timeout-2.spec.ts @@ -16,9 +16,6 @@ */ import './base.fixture'; -import utils from './utils'; -const {WIRE} = testOptions; - it('should timeout waiting for display:none to be gone', async({page, server}) => { await page.goto(server.PREFIX + '/input/button.html'); await page.$eval('button', b => b.style.display = 'none'); diff --git a/test/click-timeout-3.spec.ts b/test/click-timeout-3.spec.ts index 56060a6eef..428bdc2ffc 100644 --- a/test/click-timeout-3.spec.ts +++ b/test/click-timeout-3.spec.ts @@ -16,8 +16,7 @@ */ import './base.fixture'; -import utils from './utils'; -const {WIRE} = testOptions; +const { WIRE } = testOptions; it.skip(WIRE)('should fail when element jumps during hit testing', async({page, server}) => { await page.setContent(''); diff --git a/test/click-timeout-4.spec.ts b/test/click-timeout-4.spec.ts index 37e8ea9b1f..d4f27dd9ca 100644 --- a/test/click-timeout-4.spec.ts +++ b/test/click-timeout-4.spec.ts @@ -15,7 +15,6 @@ * limitations under the License. */ import './base.fixture'; -import utils from './utils'; it('should timeout waiting for stable position', async({page, server}) => { await page.goto(server.PREFIX + '/input/button.html'); diff --git a/test/click.spec.ts b/test/click.spec.ts index bc01aa67d0..f095a5bb96 100644 --- a/test/click.spec.ts +++ b/test/click.spec.ts @@ -15,9 +15,9 @@ * limitations under the License. */ import './base.fixture'; - import utils from './utils'; -const {FFOX, CHROMIUM, WEBKIT, HEADLESS, WIRE} = testOptions; + +const { HEADLESS } = testOptions; async function giveItAChanceToClick(page) { for (let i = 0; i < 5; i++) diff --git a/test/defaultbrowsercontext.spec.ts b/test/defaultbrowsercontext.spec.ts index ba85cb2a12..5a19f33e91 100644 --- a/test/defaultbrowsercontext.spec.ts +++ b/test/defaultbrowsercontext.spec.ts @@ -16,33 +16,24 @@ */ import './base.fixture'; import { registerFixture } from './runner/fixtures'; - import fs from 'fs'; -import path from 'path'; import utils from './utils'; -import os from 'os'; import { BrowserType, Browser, BrowserContext, Page } from '..'; -const {removeFolderAsync, mkdtempAsync, removeUserDataDir, makeUserDataDir} = utils; -const {FFOX, MAC, CHROMIUM, WEBKIT, WIN, WIRE} = testOptions; +const { removeUserDataDir, makeUserDataDir } = utils; +const { WIRE } = testOptions; declare global { interface FixtureState { - userDataDir: string; launchPersistent: (options?: Parameters['launchPersistentContext']>[1]) => Promise<{context: BrowserContext, page: Page}>; } } -registerFixture('userDataDir', async ({}, test) => { - const userDataDir = await mkdtempAsync(path.join(os.tmpdir(), 'playwright_dev_profile-')); - await test(userDataDir); - removeFolderAsync(userDataDir).catch(e => {}); -}); -registerFixture('launchPersistent', async ({userDataDir, defaultBrowserOptions, browserType}, test) => { +registerFixture('launchPersistent', async ({tmpDir, defaultBrowserOptions, browserType}, test) => { let context; async function launchPersistent(options) { if (context) throw new Error('can only launch one persitent context'); - context = await browserType.launchPersistentContext(userDataDir, {...defaultBrowserOptions, ...options}); + context = await browserType.launchPersistentContext(tmpDir, {...defaultBrowserOptions, ...options}); const page = context.pages()[0]; return {context, page}; } @@ -275,14 +266,14 @@ it('should support extraHTTPHeaders option', async ({server, launchPersistent}) expect(request.headers['foo']).toBe('bar'); }); -it('should accept userDataDir', async ({launchPersistent, userDataDir}) => { +it('should accept userDataDir', async ({launchPersistent, tmpDir}) => { const {page, context} = await launchPersistent(); // Note: we need an open page to make sure its functional. - expect(fs.readdirSync(userDataDir).length).toBeGreaterThan(0); + expect(fs.readdirSync(tmpDir).length).toBeGreaterThan(0); await context.close(); - expect(fs.readdirSync(userDataDir).length).toBeGreaterThan(0); + expect(fs.readdirSync(tmpDir).length).toBeGreaterThan(0); // This might throw. See https://github.com/GoogleChrome/puppeteer/issues/2778 - await removeUserDataDir(userDataDir); + await removeUserDataDir(tmpDir); }); it.slow()('should restore state from userDataDir', async({browserType, defaultBrowserOptions, server, launchPersistent}) => { @@ -347,20 +338,20 @@ it('should have default URL when launching browser', async ({launchPersistent}) expect(urls).toEqual(['about:blank']); }); -it.skip(FFOX)('should throw if page argument is passed', async ({browserType, defaultBrowserOptions, server, userDataDir}) => { +it.skip(FFOX)('should throw if page argument is passed', async ({browserType, defaultBrowserOptions, server, tmpDir}) => { const options = {...defaultBrowserOptions, args: [server.EMPTY_PAGE] }; - const error = await browserType.launchPersistentContext(userDataDir, options).catch(e => e); + const error = await browserType.launchPersistentContext(tmpDir, options).catch(e => e); expect(error.message).toContain('can not specify page'); }); -it.skip(WIRE)('should have passed URL when launching with ignoreDefaultArgs: true', async ({browserType, defaultBrowserOptions, server, userDataDir, toImpl}) => { - const args = toImpl(browserType)._defaultArgs(defaultBrowserOptions, 'persistent', userDataDir, 0).filter(a => a !== 'about:blank'); +it.skip(WIRE)('should have passed URL when launching with ignoreDefaultArgs: true', async ({browserType, defaultBrowserOptions, server, tmpDir, toImpl}) => { + const args = toImpl(browserType)._defaultArgs(defaultBrowserOptions, 'persistent', tmpDir, 0).filter(a => a !== 'about:blank'); const options = { ...defaultBrowserOptions, args: [...args, server.EMPTY_PAGE], ignoreDefaultArgs: true, }; - const browserContext = await browserType.launchPersistentContext(userDataDir, options); + const browserContext = await browserType.launchPersistentContext(tmpDir, options); if (!browserContext.pages().length) await browserContext.waitForEvent('page'); await browserContext.pages()[0].waitForLoadState(); @@ -369,16 +360,16 @@ it.skip(WIRE)('should have passed URL when launching with ignoreDefaultArgs: tru await browserContext.close(); }); -it.skip(WIRE)('should handle timeout', async({browserType, defaultBrowserOptions, userDataDir}) => { +it.skip(WIRE)('should handle timeout', async({browserType, defaultBrowserOptions, tmpDir}) => { const options = { ...defaultBrowserOptions, timeout: 5000, __testHookBeforeCreateBrowser: () => new Promise(f => setTimeout(f, 6000)) }; - const error = await browserType.launchPersistentContext(userDataDir, options).catch(e => e); + const error = await browserType.launchPersistentContext(tmpDir, options).catch(e => e); expect(error.message).toContain(`browserType.launchPersistentContext: Timeout 5000ms exceeded.`); }); -it.skip(WIRE)('should handle exception', async({browserType, defaultBrowserOptions, userDataDir}) => { +it.skip(WIRE)('should handle exception', async({browserType, defaultBrowserOptions, tmpDir}) => { const e = new Error('Dummy'); const options = { ...defaultBrowserOptions, __testHookBeforeCreateBrowser: () => { throw e; } }; - const error = await browserType.launchPersistentContext(userDataDir, options).catch(e => e); + const error = await browserType.launchPersistentContext(tmpDir, options).catch(e => e); expect(error.message).toContain('Dummy'); }); diff --git a/test/dialog.spec.ts b/test/dialog.spec.ts index 94396d69da..a0862fa7e1 100644 --- a/test/dialog.spec.ts +++ b/test/dialog.spec.ts @@ -16,8 +16,6 @@ */ import './base.fixture'; -const {FFOX, CHROMIUM, WEBKIT} = testOptions; - it('should fire', async({page, server}) => { page.on('dialog', dialog => { expect(dialog.type()).toBe('alert'); @@ -28,7 +26,7 @@ it('should fire', async({page, server}) => { await page.evaluate(() => alert('yo')); }); -it('should allow accepting prompts', async({page, server}) => { +it('should allow accepting prompts', async({page}) => { page.on('dialog', dialog => { expect(dialog.type()).toBe('prompt'); expect(dialog.defaultValue()).toBe('yes.'); @@ -39,7 +37,7 @@ it('should allow accepting prompts', async({page, server}) => { expect(result).toBe('answer!'); }); -it('should dismiss the prompt', async({page, server}) => { +it('should dismiss the prompt', async({page}) => { page.on('dialog', dialog => { dialog.dismiss(); }); @@ -47,7 +45,7 @@ it('should dismiss the prompt', async({page, server}) => { expect(result).toBe(null); }); -it('should accept the confirm prompt', async({page, server}) => { +it('should accept the confirm prompt', async({page}) => { page.on('dialog', dialog => { dialog.accept(); }); @@ -55,7 +53,7 @@ it('should accept the confirm prompt', async({page, server}) => { expect(result).toBe(true); }); -it('should dismiss the confirm prompt', async({page, server}) => { +it('should dismiss the confirm prompt', async({page}) => { page.on('dialog', dialog => { dialog.dismiss(); }); diff --git a/test/dispatchevent.spec.ts b/test/dispatchevent.spec.ts index f4a73c9513..5d96d8c57b 100644 --- a/test/dispatchevent.spec.ts +++ b/test/dispatchevent.spec.ts @@ -16,7 +16,6 @@ import './base.fixture'; import utils from './utils'; -const {FFOX, CHROMIUM, WEBKIT, WIN, WIRE} = testOptions; it('should dispatch click event', async({page, server}) => { await page.goto(server.PREFIX + '/input/button.html'); @@ -32,7 +31,7 @@ it('should dispatch click event properties', async({page, server}) => { expect(await page.evaluate('composed')).toBeTruthy(); }); -it('should dispatch click svg', async({page, server}) => { +it('should dispatch click svg', async({page}) => { await page.setContent(` diff --git a/test/download.spec.ts b/test/download.spec.ts index 4697be48bb..006692b099 100644 --- a/test/download.spec.ts +++ b/test/download.spec.ts @@ -19,7 +19,7 @@ import fs from 'fs'; import path from 'path'; import util from 'util'; -const {FFOX, CHROMIUM, WEBKIT, HEADLESS} = testOptions; +const { HEADLESS } = testOptions; beforeEach(async ({server}) => { server.setRoute('/download', (req, res) => { diff --git a/test/downloads-path.spec.ts b/test/downloads-path.spec.ts index 1b7d3eb68f..2acfbae624 100644 --- a/test/downloads-path.spec.ts +++ b/test/downloads-path.spec.ts @@ -24,18 +24,12 @@ import { Browser, BrowserContext } from '..'; declare global { interface FixtureState { - downloadsPath: string; downloadsBrowser: Browser; persistentDownloadsContext: BrowserContext; } } -registerFixture('downloadsPath', async ({}, test) => { - const downloadsPath = await mkdtempAsync(path.join(os.tmpdir(), 'playwright-test-')); - await test(downloadsPath); - await removeFolderAsync(downloadsPath); -}); -registerFixture('downloadsBrowser', async ({server, browserType, defaultBrowserOptions, downloadsPath}, test) => { +registerFixture('downloadsBrowser', async ({server, browserType, defaultBrowserOptions, tmpDir}, test) => { server.setRoute('/download', (req, res) => { res.setHeader('Content-Type', 'application/octet-stream'); res.setHeader('Content-Disposition', 'attachment; filename=file.txt'); @@ -43,13 +37,13 @@ registerFixture('downloadsBrowser', async ({server, browserType, defaultBrowserO }); const browser = await browserType.launch({ ...defaultBrowserOptions, - downloadsPath: downloadsPath, + downloadsPath: tmpDir, }); await test(browser); await browser.close(); }); -registerFixture('persistentDownloadsContext', async ({server, browserType, defaultBrowserOptions, downloadsPath}, test) => { +registerFixture('persistentDownloadsContext', async ({server, browserType, defaultBrowserOptions, tmpDir}, test) => { const userDataDir = await mkdtempAsync(path.join(os.tmpdir(), 'playwright-test-')); server.setRoute('/download', (req, res) => { res.setHeader('Content-Type', 'application/octet-stream'); @@ -60,7 +54,7 @@ registerFixture('persistentDownloadsContext', async ({server, browserType, defau userDataDir, { ...defaultBrowserOptions, - downloadsPath, + downloadsPath: tmpDir, acceptDownloads: true } ); @@ -71,7 +65,7 @@ registerFixture('persistentDownloadsContext', async ({server, browserType, defau await removeFolderAsync(userDataDir); }); -it('should keep downloadsPath folder', async({downloadsBrowser, downloadsPath, server}) => { +it('should keep downloadsPath folder', async({downloadsBrowser, tmpDir, server}) => { const page = await downloadsBrowser.newPage(); await page.setContent(`download`); const [ download ] = await Promise.all([ @@ -83,10 +77,10 @@ it('should keep downloadsPath folder', async({downloadsBrowser, downloadsPath, s await download.path().catch(e => void 0); await page.close(); await downloadsBrowser.close(); - expect(fs.existsSync(downloadsPath)).toBeTruthy(); + expect(fs.existsSync(tmpDir)).toBeTruthy(); }); -it('should delete downloads when context closes', async({downloadsBrowser, downloadsPath, server}) => { +it('should delete downloads when context closes', async({downloadsBrowser, server}) => { const page = await downloadsBrowser.newPage({ acceptDownloads: true }); await page.setContent(`download`); const [ download ] = await Promise.all([ @@ -100,7 +94,7 @@ it('should delete downloads when context closes', async({downloadsBrowser, downl }); -it('should report downloads in downloadsPath folder', async({downloadsBrowser, downloadsPath, server}) => { +it('should report downloads in downloadsPath folder', async({downloadsBrowser, tmpDir, server}) => { const page = await downloadsBrowser.newPage({ acceptDownloads: true }); await page.setContent(`download`); const [ download ] = await Promise.all([ @@ -108,11 +102,11 @@ it('should report downloads in downloadsPath folder', async({downloadsBrowser, d page.click('a') ]); const path = await download.path(); - expect(path.startsWith(downloadsPath)).toBeTruthy(); + expect(path.startsWith(tmpDir)).toBeTruthy(); await page.close(); }); -it('should accept downloads', async({persistentDownloadsContext, downloadsPath, server}) => { +it('should accept downloads', async({persistentDownloadsContext, tmpDir, server}) => { const page = persistentDownloadsContext.pages()[0]; const [ download ] = await Promise.all([ page.waitForEvent('download'), @@ -121,7 +115,7 @@ it('should accept downloads', async({persistentDownloadsContext, downloadsPath, expect(download.url()).toBe(`${server.PREFIX}/download`); expect(download.suggestedFilename()).toBe(`file.txt`); const path = await download.path(); - expect(path.startsWith(downloadsPath)).toBeTruthy(); + expect(path.startsWith(tmpDir)).toBeTruthy(); }); it('should not delete downloads when the context closes', async({persistentDownloadsContext}) => { diff --git a/test/electron/electron-app.spec.ts b/test/electron/electron-app.spec.ts index 0f1265841a..d59c3f7549 100644 --- a/test/electron/electron-app.spec.ts +++ b/test/electron/electron-app.spec.ts @@ -18,8 +18,6 @@ import './electron.fixture'; import path from 'path'; const electronName = process.platform === 'win32' ? 'electron.cmd' : 'electron'; -const { CHROMIUM } = testOptions; - it.skip(!CHROMIUM)('should fire close event', async ({ playwright }) => { const electronPath = path.join(__dirname, '..', '..', 'node_modules', '.bin', electronName); diff --git a/test/electron/electron-window.spec.ts b/test/electron/electron-window.spec.ts index 896db2a7e0..8bb7f7fdef 100644 --- a/test/electron/electron-window.spec.ts +++ b/test/electron/electron-window.spec.ts @@ -15,8 +15,6 @@ */ import './electron.fixture'; -const { CHROMIUM } = testOptions; - it.skip(!CHROMIUM)('should click the button', async({window, server}) => { await window.goto(server.PREFIX + '/input/button.html'); await window.click('button'); diff --git a/test/elementhandle-bounding-box.spec.ts b/test/elementhandle-bounding-box.spec.ts index 6d2567b249..89da20bd94 100644 --- a/test/elementhandle-bounding-box.spec.ts +++ b/test/elementhandle-bounding-box.spec.ts @@ -16,8 +16,7 @@ */ import './base.fixture'; -import utils from './utils'; -const { FFOX, HEADLESS } = testOptions; +const { HEADLESS } = testOptions; it.fail(FFOX && !HEADLESS)('should work', async ({ page, server }) => { await page.setViewportSize({ width: 500, height: 500 }); diff --git a/test/elementhandle-click.spec.ts b/test/elementhandle-click.spec.ts index 38bca7874f..987316f0d4 100644 --- a/test/elementhandle-click.spec.ts +++ b/test/elementhandle-click.spec.ts @@ -16,9 +16,6 @@ */ import './base.fixture'; -import utils from './utils'; -const { FFOX, HEADLESS } = testOptions; - it('should work', async ({ page, server }) => { await page.goto(server.PREFIX + '/input/button.html'); const button = await page.$('button'); diff --git a/test/elementhandle-content-frame.spec.ts b/test/elementhandle-content-frame.spec.ts index 8642d22eed..90313ae07e 100644 --- a/test/elementhandle-content-frame.spec.ts +++ b/test/elementhandle-content-frame.spec.ts @@ -17,7 +17,6 @@ import './base.fixture'; import utils from './utils'; -const { FFOX, HEADLESS } = testOptions; it('should work', async ({ page, server }) => { await page.goto(server.EMPTY_PAGE); diff --git a/test/elementhandle-convenience.spec.ts b/test/elementhandle-convenience.spec.ts index 2e20d5d08d..22ddf96948 100644 --- a/test/elementhandle-convenience.spec.ts +++ b/test/elementhandle-convenience.spec.ts @@ -17,7 +17,6 @@ import './base.fixture'; import utils from './utils'; -const { FFOX, HEADLESS } = testOptions; it('should have a nice preview', async ({ page, server }) => { await page.goto(`${server.PREFIX}/dom.html`); diff --git a/test/elementhandle-eval-on-selector.spec.ts b/test/elementhandle-eval-on-selector.spec.ts index 65735ce83e..84c14663a1 100644 --- a/test/elementhandle-eval-on-selector.spec.ts +++ b/test/elementhandle-eval-on-selector.spec.ts @@ -16,10 +16,6 @@ */ import './base.fixture'; -import path from 'path'; -import utils from './utils'; -const {FFOX, CHROMIUM, WEBKIT, WIRE} = testOptions; - it('should work', async({page, server}) => { await page.setContent('
10
'); const tweet = await page.$('.tweet'); diff --git a/test/elementhandle-misc.spec.ts b/test/elementhandle-misc.spec.ts index 5cf08e8471..9d9966d647 100644 --- a/test/elementhandle-misc.spec.ts +++ b/test/elementhandle-misc.spec.ts @@ -16,9 +16,6 @@ */ import './base.fixture'; -import utils from './utils'; -const { FFOX, HEADLESS } = testOptions; - it('should hover', async ({ page, server }) => { await page.goto(server.PREFIX + '/input/scrollable.html'); const button = await page.$('#button-6'); diff --git a/test/elementhandle-owner-frame.spec.ts b/test/elementhandle-owner-frame.spec.ts index 6539951a74..88b9dcac80 100644 --- a/test/elementhandle-owner-frame.spec.ts +++ b/test/elementhandle-owner-frame.spec.ts @@ -17,7 +17,6 @@ import './base.fixture'; import utils from './utils'; -const { FFOX, HEADLESS } = testOptions; it('should work', async ({ page, server }) => { await page.goto(server.EMPTY_PAGE); diff --git a/test/elementhandle-press.spec.ts b/test/elementhandle-press.spec.ts index 6478190501..101c4e0e3c 100644 --- a/test/elementhandle-press.spec.ts +++ b/test/elementhandle-press.spec.ts @@ -16,9 +16,6 @@ */ import './base.fixture'; -import utils from './utils'; -const { FFOX, HEADLESS } = testOptions; - it('should work', async ({ page }) => { await page.setContent(``); await page.press('input', 'h'); diff --git a/test/elementhandle-query-selector.spec.ts b/test/elementhandle-query-selector.spec.ts index 2f2681caae..846bdd8c51 100644 --- a/test/elementhandle-query-selector.spec.ts +++ b/test/elementhandle-query-selector.spec.ts @@ -16,10 +16,6 @@ */ import './base.fixture'; -import path from 'path'; -import utils from './utils'; -const {FFOX, CHROMIUM, WEBKIT, WIRE} = testOptions; - it('should query existing element', async({page, server}) => { await page.goto(server.PREFIX + '/playground.html'); await page.setContent('
A
'); diff --git a/test/elementhandle-screenshot.spec.ts b/test/elementhandle-screenshot.spec.ts index 3eb8b57f19..71f92c63be 100644 --- a/test/elementhandle-screenshot.spec.ts +++ b/test/elementhandle-screenshot.spec.ts @@ -17,7 +17,7 @@ import './base.fixture'; import utils from './utils'; -const {FFOX, CHROMIUM, WEBKIT, WIRE, HEADLESS} = testOptions; +const {WIRE, HEADLESS} = testOptions; import {PNG} from 'pngjs'; // Firefox headful produces a different image. diff --git a/test/elementhandle-scroll-into-view.spec.ts b/test/elementhandle-scroll-into-view.spec.ts index 7b2725b2f9..231a0fc28c 100644 --- a/test/elementhandle-scroll-into-view.spec.ts +++ b/test/elementhandle-scroll-into-view.spec.ts @@ -16,9 +16,6 @@ */ import './base.fixture'; -import utils from './utils'; -const { FFOX, HEADLESS } = testOptions; - it('should work', async ({ page, server }) => { await page.goto(server.PREFIX + '/offscreenbuttons.html'); for (let i = 0; i < 11; ++i) { diff --git a/test/elementhandle-select-text.spec.ts b/test/elementhandle-select-text.spec.ts index 731a145e3b..ce23882a59 100644 --- a/test/elementhandle-select-text.spec.ts +++ b/test/elementhandle-select-text.spec.ts @@ -16,9 +16,6 @@ */ import './base.fixture'; -import utils from './utils'; -const { FFOX, HEADLESS } = testOptions; - it('should select textarea', async ({ page, server }) => { await page.goto(server.PREFIX + '/input/textarea.html'); const textarea = await page.$('textarea'); diff --git a/test/elementhandle-type.spec.ts b/test/elementhandle-type.spec.ts index 07db2ce484..7405c21d21 100644 --- a/test/elementhandle-type.spec.ts +++ b/test/elementhandle-type.spec.ts @@ -16,9 +16,6 @@ */ import './base.fixture'; -import utils from './utils'; -const { FFOX, HEADLESS } = testOptions; - it('should work', async ({ page }) => { await page.setContent(``); await page.type('input', 'hello'); diff --git a/test/emulation-focus.spec.ts b/test/emulation-focus.spec.ts index 3a46221bb3..ae2dd8e1d5 100644 --- a/test/emulation-focus.spec.ts +++ b/test/emulation-focus.spec.ts @@ -17,7 +17,7 @@ import './base.fixture'; import utils from './utils'; -const {CHROMIUM, FFOX, MAC, HEADLESS} = testOptions; +const { HEADLESS } = testOptions; it('should think that it is focused by default', async({page}) => { expect(await page.evaluate('document.hasFocus()')).toBe(true); diff --git a/test/eval-on-selector-all.spec.ts b/test/eval-on-selector-all.spec.ts index 21262cee08..1045a900dc 100644 --- a/test/eval-on-selector-all.spec.ts +++ b/test/eval-on-selector-all.spec.ts @@ -16,10 +16,6 @@ */ import './base.fixture'; -import path from 'path'; -import utils from './utils'; -const {FFOX, CHROMIUM, WEBKIT, WIRE} = testOptions; - it('should work with css selector', async({page, server}) => { await page.setContent('
hello
beautiful
world!
'); const divsCount = await page.$$eval('css=div', divs => divs.length); diff --git a/test/eval-on-selector.spec.ts b/test/eval-on-selector.spec.ts index 05bf26ebe5..2d976b6a43 100644 --- a/test/eval-on-selector.spec.ts +++ b/test/eval-on-selector.spec.ts @@ -16,10 +16,6 @@ */ import './base.fixture'; -import path from 'path'; -import utils from './utils'; -const {FFOX, CHROMIUM, WEBKIT, WIRE} = testOptions; - it('should work with css selector', async({page, server}) => { await page.setContent('
43543
'); const idAttribute = await page.$eval('css=section', e => e.id); diff --git a/test/firefox/launcher.spec.ts b/test/firefox/launcher.spec.ts index 60828fc115..609a5f0c9c 100644 --- a/test/firefox/launcher.spec.ts +++ b/test/firefox/launcher.spec.ts @@ -15,8 +15,6 @@ */ import '../base.fixture'; -const { FFOX } = testOptions; - it.skip(!FFOX)('should pass firefox user preferences', async({browserType, defaultBrowserOptions}) => { const browser = await browserType.launch({ ...defaultBrowserOptions, diff --git a/test/fixtures.spec.ts b/test/fixtures.spec.ts index fd873c0264..a2bc98e582 100644 --- a/test/fixtures.spec.ts +++ b/test/fixtures.spec.ts @@ -20,7 +20,7 @@ import { registerFixture } from './runner/fixtures'; import path from 'path'; import {spawn, execSync} from 'child_process'; import { BrowserType, Browser, LaunchOptions } from '..'; -const {FFOX, CHROMIUM, WEBKIT, WIN, LINUX, HEADLESS} = testOptions; +const { HEADLESS } = testOptions; const playwrightPath = path.join(__dirname, '..'); diff --git a/test/focus.spec.ts b/test/focus.spec.ts index 1c0aca878c..28053f4516 100644 --- a/test/focus.spec.ts +++ b/test/focus.spec.ts @@ -15,8 +15,6 @@ */ import './base.fixture'; -const {FFOX, CHROMIUM, LINUX, WEBKIT, MAC} = testOptions; - it('should work', async function({page, server}) { await page.setContent(`
`); expect(await page.evaluate(() => document.activeElement.nodeName)).toBe('BODY'); diff --git a/test/frame-evaluate.spec.ts b/test/frame-evaluate.spec.ts index dd2cb50b12..3df5ba3d94 100644 --- a/test/frame-evaluate.spec.ts +++ b/test/frame-evaluate.spec.ts @@ -17,8 +17,7 @@ import './base.fixture'; import utils from './utils'; -import path from 'path'; -const { FFOX, CHROMIUM, WEBKIT, WIRE } = testOptions; +const { WIRE } = testOptions; it('should have different execution contexts', async ({ page, server }) => { await page.goto(server.EMPTY_PAGE); diff --git a/test/frame-frame-element.spec.ts b/test/frame-frame-element.spec.ts index 4e1fae9b39..2f216abc53 100644 --- a/test/frame-frame-element.spec.ts +++ b/test/frame-frame-element.spec.ts @@ -17,7 +17,6 @@ import './base.fixture'; import utils from './utils'; -const {FFOX, CHROMIUM, WEBKIT} = testOptions; it('should work', async({page, server}) => { await page.goto(server.EMPTY_PAGE); diff --git a/test/frame-goto.spec.ts b/test/frame-goto.spec.ts index d92a567060..f76fc6b529 100644 --- a/test/frame-goto.spec.ts +++ b/test/frame-goto.spec.ts @@ -17,9 +17,6 @@ import './base.fixture'; import utils from './utils'; -import path from 'path'; -import url from 'url'; -const {FFOX, CHROMIUM, WEBKIT, MAC, WIN} = testOptions; it('should navigate subframes', async({page, server}) => { await page.goto(server.PREFIX + '/frames/one-frame.html'); diff --git a/test/frame-hierarchy.spec.ts b/test/frame-hierarchy.spec.ts index 5eda2cb38d..b332b9eb72 100644 --- a/test/frame-hierarchy.spec.ts +++ b/test/frame-hierarchy.spec.ts @@ -17,7 +17,6 @@ import './base.fixture'; import utils from './utils'; -const {FFOX, CHROMIUM, WEBKIT} = testOptions; it('should handle nested frames', async({page, server}) => { await page.goto(server.PREFIX + '/frames/nested-frames.html'); diff --git a/test/geolocation.spec.ts b/test/geolocation.spec.ts index e50c6837d6..008fe5d957 100644 --- a/test/geolocation.spec.ts +++ b/test/geolocation.spec.ts @@ -16,8 +16,6 @@ */ import './base.fixture'; -const {FFOX, CHROMIUM, WEBKIT} = testOptions; - it('should work', async({page, server, context}) => { await context.grantPermissions(['geolocation']); await page.goto(server.EMPTY_PAGE); diff --git a/test/headful.spec.ts b/test/headful.spec.ts index bd1b67e5ae..cfe6b837b3 100644 --- a/test/headful.spec.ts +++ b/test/headful.spec.ts @@ -17,15 +17,12 @@ import './base.fixture'; import utils from './utils'; const { makeUserDataDir, removeUserDataDir } = utils; -const {FFOX, CHROMIUM, WEBKIT, WIN, MAC} = testOptions; -it('should have default url when launching browser', async ({browserType, defaultBrowserOptions}) => { - const userDataDir = await makeUserDataDir(); - const browserContext = await browserType.launchPersistentContext(userDataDir, {...defaultBrowserOptions, headless: false }); +it('should have default url when launching browser', async ({browserType, defaultBrowserOptions, tmpDir}) => { + const browserContext = await browserType.launchPersistentContext(tmpDir, {...defaultBrowserOptions, headless: false }); const urls = browserContext.pages().map(page => page.url()); expect(urls).toEqual(['about:blank']); await browserContext.close(); - await removeUserDataDir(userDataDir); }); it.fail(WIN && CHROMIUM).slow()('headless should be able to read cookies written by headful', async({browserType, defaultBrowserOptions, server}) => { @@ -48,19 +45,17 @@ it.fail(WIN && CHROMIUM).slow()('headless should be able to read cookies written expect(cookie).toBe('foo=true'); }); -it.slow()('should close browser with beforeunload page', async({browserType, defaultBrowserOptions, server}) => { - const userDataDir = await makeUserDataDir(); - const browserContext = await browserType.launchPersistentContext(userDataDir, {...defaultBrowserOptions, headless: false}); +it.slow()('should close browser with beforeunload page', async({browserType, defaultBrowserOptions, server, tmpDir}) => { + const browserContext = await browserType.launchPersistentContext(tmpDir, {...defaultBrowserOptions, headless: false}); const page = await browserContext.newPage(); await page.goto(server.PREFIX + '/beforeunload.html'); // We have to interact with a page so that 'beforeunload' handlers // fire. await page.click('body'); await browserContext.close(); - await removeUserDataDir(userDataDir); }); -it('should not crash when creating second context', async ({browserType, defaultBrowserOptions, server}) => { +it('should not crash when creating second context', async ({browserType, defaultBrowserOptions}) => { const browser = await browserType.launch({...defaultBrowserOptions, headless: false }); { const browserContext = await browser.newContext(); diff --git a/test/ignorehttpserrors.spec.ts b/test/ignorehttpserrors.spec.ts index 9d24a6474d..e8aa629e50 100644 --- a/test/ignorehttpserrors.spec.ts +++ b/test/ignorehttpserrors.spec.ts @@ -16,8 +16,6 @@ */ import './base.fixture'; -const {FFOX, CHROMIUM, WEBKIT, MAC} = testOptions; - it('should work', async({browser, httpsServer}) => { let error = null; const context = await browser.newContext({ ignoreHTTPSErrors: true }); diff --git a/test/interception.spec.ts b/test/interception.spec.ts index 5f1b34b5b9..ff0d6601b4 100644 --- a/test/interception.spec.ts +++ b/test/interception.spec.ts @@ -16,11 +16,8 @@ */ import './base.fixture'; -import fs from 'fs'; -import path from 'path'; import { helper } from '../lib/helper'; import vm from 'vm'; -const {FFOX, CHROMIUM, WEBKIT, HEADLESS} = testOptions; it('should work with navigation', async({page, server}) => { const requests = new Map(); diff --git a/test/jshandle-as-element.spec.ts b/test/jshandle-as-element.spec.ts index aa0b8fa4ed..f0ac3cc0b9 100644 --- a/test/jshandle-as-element.spec.ts +++ b/test/jshandle-as-element.spec.ts @@ -16,21 +16,19 @@ */ import './base.fixture'; -const {FFOX, CHROMIUM, WEBKIT} = testOptions; - -it('should work', async({page, server}) => { +it('should work', async({page}) => { const aHandle = await page.evaluateHandle(() => document.body); const element = aHandle.asElement(); expect(element).toBeTruthy(); }); -it('should return null for non-elements', async({page, server}) => { +it('should return null for non-elements', async({page}) => { const aHandle = await page.evaluateHandle(() => 2); const element = aHandle.asElement(); expect(element).toBeFalsy(); }); -it('should return ElementHandle for TextNodes', async({page, server}) => { +it('should return ElementHandle for TextNodes', async({page}) => { await page.setContent('
ee!
'); const aHandle = await page.evaluateHandle(() => document.querySelector('div').firstChild); const element = aHandle.asElement(); @@ -38,7 +36,7 @@ it('should return ElementHandle for TextNodes', async({page, server}) => { expect(await page.evaluate(e => e.nodeType === Node.TEXT_NODE, element)).toBeTruthy(); }); -it('should work with nullified Node', async({page, server}) => { +it('should work with nullified Node', async({page}) => { await page.setContent('
test
'); await page.evaluate('delete Node'); const handle = await page.evaluateHandle(() => document.querySelector('section')); diff --git a/test/jshandle-evaluate.spec.ts b/test/jshandle-evaluate.spec.ts index 09881b4826..aaccd85d51 100644 --- a/test/jshandle-evaluate.spec.ts +++ b/test/jshandle-evaluate.spec.ts @@ -16,9 +16,7 @@ */ import './base.fixture'; -const {FFOX, CHROMIUM, WEBKIT} = testOptions; - -it('should work with function', async({page, server}) => { +it('should work with function', async({page}) => { const windowHandle = await page.evaluateHandle(() => { window['foo'] = [1, 2]; return window; @@ -26,7 +24,7 @@ it('should work with function', async({page, server}) => { expect(await windowHandle.evaluate(w => w['foo'])).toEqual([1, 2]); }); -it('should work with expression', async({page, server}) => { +it('should work with expression', async({page}) => { const windowHandle = await page.evaluateHandle(() => { window['foo'] = [1, 2]; return window; diff --git a/test/jshandle-json-value.spec.ts b/test/jshandle-json-value.spec.ts index 73d4c00033..21761352b9 100644 --- a/test/jshandle-json-value.spec.ts +++ b/test/jshandle-json-value.spec.ts @@ -16,21 +16,19 @@ */ import './base.fixture'; -const {FFOX, CHROMIUM, WEBKIT} = testOptions; - -it('should work', async({page, server}) => { +it('should work', async({page}) => { const aHandle = await page.evaluateHandle(() => ({foo: 'bar'})); const json = await aHandle.jsonValue(); expect(json).toEqual({foo: 'bar'}); }); -it('should work with dates', async({page, server}) => { +it('should work with dates', async({page}) => { const dateHandle = await page.evaluateHandle(() => new Date('2017-09-26T00:00:00.000Z')); const date = await dateHandle.jsonValue(); expect(date.toJSON()).toBe('2017-09-26T00:00:00.000Z'); }); -it('should throw for circular objects', async({page, server}) => { +it('should throw for circular objects', async({page}) => { const windowHandle = await page.evaluateHandle('window'); let error = null; await windowHandle.jsonValue().catch(e => error = e); diff --git a/test/jshandle-properties.spec.ts b/test/jshandle-properties.spec.ts index e5e6df2e68..a29dfd764a 100644 --- a/test/jshandle-properties.spec.ts +++ b/test/jshandle-properties.spec.ts @@ -16,9 +16,7 @@ */ import './base.fixture'; -const {FFOX, CHROMIUM, WEBKIT} = testOptions; - -it('should work', async({page, server}) => { +it('should work', async({page}) => { const aHandle = await page.evaluateHandle(() => ({ one: 1, two: 2, @@ -28,7 +26,7 @@ it('should work', async({page, server}) => { expect(await twoHandle.jsonValue()).toEqual(2); }); -it('should work with undefined, null, and empty', async({page, server}) => { +it('should work with undefined, null, and empty', async({page}) => { const aHandle = await page.evaluateHandle(() => ({ undefined: undefined, null: null, @@ -41,7 +39,7 @@ it('should work with undefined, null, and empty', async({page, server}) => { expect(String(await emptyhandle.jsonValue())).toEqual('undefined'); }); -it('should work with unserializable values', async({page, server}) => { +it('should work with unserializable values', async({page}) => { const aHandle = await page.evaluateHandle(() => ({ infinity: Infinity, nInfinity: -Infinity, @@ -58,7 +56,7 @@ it('should work with unserializable values', async({page, server}) => { expect(await nzeroHandle.jsonValue()).toEqual(-0); }); -it('getProperties should work', async({page, server}) => { +it('getProperties should work', async({page}) => { const aHandle = await page.evaluateHandle(() => ({ foo: 'bar' })); @@ -68,13 +66,13 @@ it('getProperties should work', async({page, server}) => { expect(await foo.jsonValue()).toBe('bar'); }); -it('getProperties should return empty map for non-objects', async({page, server}) => { +it('getProperties should return empty map for non-objects', async({page}) => { const aHandle = await page.evaluateHandle(() => 123); const properties = await aHandle.getProperties(); expect(properties.size).toBe(0); }); -it('getProperties should return even non-own properties', async({page, server}) => { +it('getProperties should return even non-own properties', async({page}) => { const aHandle = await page.evaluateHandle(() => { class A { a: string; diff --git a/test/jshandle-to-string.spec.ts b/test/jshandle-to-string.spec.ts index cdf70895e6..448cd61588 100644 --- a/test/jshandle-to-string.spec.ts +++ b/test/jshandle-to-string.spec.ts @@ -16,28 +16,26 @@ */ import './base.fixture'; -const {FFOX, CHROMIUM, WEBKIT} = testOptions; - -it('should work for primitives', async({page, server}) => { +it('should work for primitives', async({page}) => { const numberHandle = await page.evaluateHandle(() => 2); expect(numberHandle.toString()).toBe('JSHandle@2'); const stringHandle = await page.evaluateHandle(() => 'a'); expect(stringHandle.toString()).toBe('JSHandle@a'); }); -it('should work for complicated objects', async({page, server}) => { +it('should work for complicated objects', async({page}) => { const aHandle = await page.evaluateHandle(() => window); expect(aHandle.toString()).toBe('JSHandle@object'); }); -it('should work for promises', async({page, server}) => { +it('should work for promises', async({page}) => { // wrap the promise in an object, otherwise we will await. const wrapperHandle = await page.evaluateHandle(() => ({b: Promise.resolve(123)})); const bHandle = await wrapperHandle.getProperty('b'); expect(bHandle.toString()).toBe('JSHandle@promise'); }); -it('should work with different subtypes', async({page, server}) => { +it('should work with different subtypes', async({page}) => { expect((await page.evaluateHandle('(function(){})')).toString()).toBe('JSHandle@function'); expect((await page.evaluateHandle('12')).toString()).toBe('JSHandle@12'); expect((await page.evaluateHandle('true')).toString()).toBe('JSHandle@true'); diff --git a/test/keyboard.spec.ts b/test/keyboard.spec.ts index ee3bc24e0b..8b5f94d1de 100644 --- a/test/keyboard.spec.ts +++ b/test/keyboard.spec.ts @@ -18,9 +18,7 @@ import './base.fixture'; import utils from './utils'; -const {FFOX, WEBKIT, CHROMIUM, MAC} = testOptions; - -it('should type into a textarea', async ({page, server}) => { +it('should type into a textarea', async ({page}) => { await page.evaluate(() => { const textarea = document.createElement('textarea'); document.body.appendChild(textarea); diff --git a/test/launcher.spec.ts b/test/launcher.spec.ts index b477d01c94..f9e427a2b5 100644 --- a/test/launcher.spec.ts +++ b/test/launcher.spec.ts @@ -17,11 +17,9 @@ import './base.fixture'; import path from 'path'; -import fs from 'fs'; import utils from './utils'; -const {FFOX, CHROMIUM, WEBKIT, WIN, WIRE} = testOptions; -it('should require top-level Errors', async({playwright}) => { +it('should require top-level Errors', async({}) => { const Errors = require(path.join(utils.projectRoot(), '/lib/errors.js')); expect(String(Errors.TimeoutError)).toContain('TimeoutError'); }); diff --git a/test/logger.spec.ts b/test/logger.spec.ts index fa6d923e06..e053afa7d5 100644 --- a/test/logger.spec.ts +++ b/test/logger.spec.ts @@ -15,10 +15,6 @@ */ import './base.fixture'; -import fs from 'fs'; -import path from 'path'; -const {FFOX, CHROMIUM, WEBKIT} = testOptions; - it('should log', async({browserType, defaultBrowserOptions}) => { const log = []; const browser = await browserType.launch({...defaultBrowserOptions, logger: { diff --git a/test/mouse.spec.ts b/test/mouse.spec.ts index 779d44cf70..0d39149229 100644 --- a/test/mouse.spec.ts +++ b/test/mouse.spec.ts @@ -16,8 +16,6 @@ */ import './base.fixture'; -const {FFOX, CHROMIUM, WEBKIT, MAC, WIN} = testOptions; - function dimensions() { const rect = document.querySelector('textarea').getBoundingClientRect(); return { diff --git a/test/multiclient.spec.ts b/test/multiclient.spec.ts index e27507ee17..24ed22912c 100644 --- a/test/multiclient.spec.ts +++ b/test/multiclient.spec.ts @@ -16,7 +16,7 @@ */ import './base.fixture'; -const {FFOX, CHROMIUM, WEBKIT, WIRE} = testOptions; +const { WIRE } = testOptions; it.skip(WIRE)('should work across sessions', async ({browserType, defaultBrowserOptions}) => { const browserServer = await browserType.launchServer(defaultBrowserOptions); diff --git a/test/network-request.spec.ts b/test/network-request.spec.ts index 979014c86f..fcf08e4bb4 100644 --- a/test/network-request.spec.ts +++ b/test/network-request.spec.ts @@ -16,10 +16,7 @@ */ import './base.fixture'; -import fs from 'fs'; -import path from 'path'; import utils from './utils'; -const {FFOX, CHROMIUM, WEBKIT, MAC, WIN} = testOptions; it('should work for main frame navigation request', async({page, server}) => { const requests = []; diff --git a/test/network-response.spec.ts b/test/network-response.spec.ts index e238a8e130..03bc26e4af 100644 --- a/test/network-response.spec.ts +++ b/test/network-response.spec.ts @@ -18,8 +18,6 @@ import './base.fixture'; import fs from 'fs'; import path from 'path'; -import utils from './utils'; -const {FFOX, CHROMIUM, WEBKIT, MAC, WIN} = testOptions; it('should work', async({page, server}) => { server.setRoute('/empty.html', (req, res) => { diff --git a/test/page-add-init-script.spec.ts b/test/page-add-init-script.spec.ts index a682746b8d..7acfd0db3d 100644 --- a/test/page-add-init-script.spec.ts +++ b/test/page-add-init-script.spec.ts @@ -16,9 +16,7 @@ */ import './base.fixture'; -import utils from './utils'; import path from 'path'; -const { FFOX, CHROMIUM, WEBKIT, WIRE } = testOptions; it('should evaluate before anything else on the page', async ({ page, server }) => { await page.addInitScript(function () { diff --git a/test/page-add-script-tag.spec.ts b/test/page-add-script-tag.spec.ts index 283983356d..9a60192913 100644 --- a/test/page-add-script-tag.spec.ts +++ b/test/page-add-script-tag.spec.ts @@ -17,9 +17,6 @@ import './base.fixture'; import path from 'path'; -import util from 'util'; -import vm from 'vm'; -const {FFOX, CHROMIUM, WEBKIT, WIN, WIRE} = testOptions; it('should throw an error if no options are provided', async({page, server}) => { let error = null; diff --git a/test/page-add-style-tag.spec.ts b/test/page-add-style-tag.spec.ts index 9b4cc56c28..98cf349d03 100644 --- a/test/page-add-style-tag.spec.ts +++ b/test/page-add-style-tag.spec.ts @@ -17,9 +17,6 @@ import './base.fixture'; import path from 'path'; -import util from 'util'; -import vm from 'vm'; -const {FFOX, CHROMIUM, WEBKIT, WIN, WIRE} = testOptions; it('should throw an error if no options are provided', async({page, server}) => { let error = null; diff --git a/test/page-basic.spec.ts b/test/page-basic.spec.ts index 63cfe87863..f2c6b35ca5 100644 --- a/test/page-basic.spec.ts +++ b/test/page-basic.spec.ts @@ -16,11 +16,6 @@ */ import './base.fixture'; -import path from 'path'; -import util from 'util'; -import vm from 'vm'; -const {FFOX, CHROMIUM, WEBKIT, WIN, WIRE} = testOptions; - it('should reject all promises when page is closed', async({context}) => { const newPage = await context.newPage(); let error = null; diff --git a/test/page-emulate-media.spec.ts b/test/page-emulate-media.spec.ts index e695c91d0c..d673826d38 100644 --- a/test/page-emulate-media.spec.ts +++ b/test/page-emulate-media.spec.ts @@ -17,7 +17,6 @@ import './base.fixture'; import utils from './utils'; -const {CHROMIUM, FFOX, MAC, HEADLESS} = testOptions; it('should emulate type', async({page, server}) => { expect(await page.evaluate(() => matchMedia('screen').matches)).toBe(true); diff --git a/test/page-evaluate-handle.spec.ts b/test/page-evaluate-handle.spec.ts index 7f894c4de1..411dad487a 100644 --- a/test/page-evaluate-handle.spec.ts +++ b/test/page-evaluate-handle.spec.ts @@ -16,8 +16,6 @@ */ import './base.fixture'; -const {FFOX, CHROMIUM, WEBKIT} = testOptions; - it('should work', async({page, server}) => { const windowHandle = await page.evaluateHandle(() => window); expect(windowHandle).toBeTruthy(); diff --git a/test/page-evaluate.spec.ts b/test/page-evaluate.spec.ts index 8ed0c27001..695ab33c45 100644 --- a/test/page-evaluate.spec.ts +++ b/test/page-evaluate.spec.ts @@ -15,8 +15,7 @@ * limitations under the License. */ import './base.fixture'; - -const {WEBKIT, WIRE, FFOX} = testOptions; +const { WIRE } = testOptions; it('should work', async ({ page, server }) => { const result = await page.evaluate(() => 7 * 3); diff --git a/test/page-event-console.spec.ts b/test/page-event-console.spec.ts index 2b5b745ef3..e970136bc7 100644 --- a/test/page-event-console.spec.ts +++ b/test/page-event-console.spec.ts @@ -16,10 +16,7 @@ */ import './base.fixture'; -import path from 'path'; import util from 'util'; -import vm from 'vm'; -const {FFOX, CHROMIUM, WEBKIT, WIN, WIRE} = testOptions; it('should work', async({page, server}) => { let message = null; diff --git a/test/page-event-crash.spec.ts b/test/page-event-crash.spec.ts index e6fa1797de..6021d0c328 100644 --- a/test/page-event-crash.spec.ts +++ b/test/page-event-crash.spec.ts @@ -16,10 +16,7 @@ */ import './base.fixture'; -import path from 'path'; -import util from 'util'; -import vm from 'vm'; -const {FFOX, CHROMIUM, WEBKIT, WIN, WIRE} = testOptions; +const { WIRE } = testOptions; const CRASH_FAIL = (FFOX && WIN) || WIRE; // Firefox Win: it just doesn't crash sometimes. diff --git a/test/page-event-network.spec.ts b/test/page-event-network.spec.ts index f51b8f3d72..5c1171e7ad 100644 --- a/test/page-event-network.spec.ts +++ b/test/page-event-network.spec.ts @@ -16,11 +16,6 @@ */ import './base.fixture'; -import fs from 'fs'; -import path from 'path'; -import utils from './utils'; -const {FFOX, CHROMIUM, WEBKIT, MAC, WIN} = testOptions; - it('Page.Events.Request', async({page, server}) => { const requests = []; page.on('request', request => requests.push(request)); diff --git a/test/page-event-pageerror.spec.ts b/test/page-event-pageerror.spec.ts index daa5b69e5a..41d87aadf3 100644 --- a/test/page-event-pageerror.spec.ts +++ b/test/page-event-pageerror.spec.ts @@ -16,9 +16,6 @@ */ import './base.fixture'; -import path from 'path'; -const {FFOX, CHROMIUM, WEBKIT, WIN, WIRE} = testOptions; - it('should fire', async({page, server}) => { const [error] = await Promise.all([ page.waitForEvent('pageerror'), diff --git a/test/page-event-popup.spec.ts b/test/page-event-popup.spec.ts index 867a0021cd..8930b2c306 100644 --- a/test/page-event-popup.spec.ts +++ b/test/page-event-popup.spec.ts @@ -15,8 +15,6 @@ */ import './base.fixture'; -const {FFOX, CHROMIUM, WEBKIT, MAC} = testOptions; - it('should work', async({browser}) => { const context = await browser.newContext(); const page = await context.newPage(); diff --git a/test/page-event-request.spec.ts b/test/page-event-request.spec.ts index d4ed1ef115..95d5103524 100644 --- a/test/page-event-request.spec.ts +++ b/test/page-event-request.spec.ts @@ -16,10 +16,7 @@ */ import './base.fixture'; -import fs from 'fs'; -import path from 'path'; import utils from './utils'; -const {FFOX, CHROMIUM, WEBKIT, MAC, WIN} = testOptions; it('should fire for navigation requests', async({page, server}) => { const requests = []; diff --git a/test/page-expose-function.spec.ts b/test/page-expose-function.spec.ts index 504e2bbb6e..afd2838f25 100644 --- a/test/page-expose-function.spec.ts +++ b/test/page-expose-function.spec.ts @@ -16,11 +16,6 @@ */ import './base.fixture'; -import path from 'path'; -import util from 'util'; -import vm from 'vm'; -const {FFOX, CHROMIUM, WEBKIT, WIN, WIRE} = testOptions; - it('exposeBinding should work', async({browser}) => { const context = await browser.newContext(); const page = await context.newPage(); diff --git a/test/page-fill.spec.ts b/test/page-fill.spec.ts index 5072bbcbf1..ea9d38b0b7 100644 --- a/test/page-fill.spec.ts +++ b/test/page-fill.spec.ts @@ -16,11 +16,6 @@ */ import './base.fixture'; -import path from 'path'; -import util from 'util'; -import vm from 'vm'; -const {FFOX, CHROMIUM, WEBKIT, WIN, WIRE} = testOptions; - async function giveItAChanceToFill(page) { for (let i = 0; i < 5; i++) await page.evaluate(() => new Promise(f => requestAnimationFrame(() => requestAnimationFrame(f)))); diff --git a/test/page-goto.spec.ts b/test/page-goto.spec.ts index d3ff22ca91..39e97a98e8 100644 --- a/test/page-goto.spec.ts +++ b/test/page-goto.spec.ts @@ -19,7 +19,6 @@ import './base.fixture'; import utils from './utils'; import path from 'path'; import url from 'url'; -const {FFOX, CHROMIUM, WEBKIT, MAC, WIN} = testOptions; it('should work', async({page, server}) => { await page.goto(server.EMPTY_PAGE); diff --git a/test/page-history.spec.ts b/test/page-history.spec.ts index 33511d164a..d3593614ad 100644 --- a/test/page-history.spec.ts +++ b/test/page-history.spec.ts @@ -16,9 +16,7 @@ */ import './base.fixture'; -import path from 'path'; import url from 'url'; -const {FFOX, CHROMIUM, WEBKIT, MAC, WIN} = testOptions; it('page.goBack should work', async({page, server}) => { expect(await page.goBack()).toBe(null); diff --git a/test/page-network-idle.spec.ts b/test/page-network-idle.spec.ts index c7912da903..838dd9d123 100644 --- a/test/page-network-idle.spec.ts +++ b/test/page-network-idle.spec.ts @@ -16,12 +16,8 @@ */ import './base.fixture'; -import utils from './utils'; -import path from 'path'; -import url from 'url'; import { Frame, Page } from '..'; import { TestServer } from '../utils/testserver'; -const {FFOX, CHROMIUM, WEBKIT, MAC, WIN} = testOptions; it('should navigate to empty page with networkidle', async({page, server}) => { const response = await page.goto(server.EMPTY_PAGE, { waitUntil: 'networkidle' }); diff --git a/test/page-route.spec.ts b/test/page-route.spec.ts index edff4714be..7db2d3caab 100644 --- a/test/page-route.spec.ts +++ b/test/page-route.spec.ts @@ -16,12 +16,6 @@ */ import './base.fixture'; -import fs from 'fs'; -import path from 'path'; -import { helper } from '../lib/helper'; -import vm from 'vm'; -const {FFOX, CHROMIUM, WEBKIT, HEADLESS} = testOptions; - it('should intercept', async({page, server}) => { let intercepted = false; await page.route('**/empty.html', (route, request) => { diff --git a/test/page-screenshot.spec.ts b/test/page-screenshot.spec.ts index b1f1094457..750c148be4 100644 --- a/test/page-screenshot.spec.ts +++ b/test/page-screenshot.spec.ts @@ -15,9 +15,8 @@ * limitations under the License. */ import './base.fixture'; - import utils from './utils'; -const {FFOX, WEBKIT, HEADLESS} = testOptions; +const { HEADLESS } = testOptions; // Firefox headful produces a different image. const ffheadful = FFOX && !HEADLESS; diff --git a/test/page-select-option.spec.ts b/test/page-select-option.spec.ts index 579239220f..953c07ea8b 100644 --- a/test/page-select-option.spec.ts +++ b/test/page-select-option.spec.ts @@ -16,11 +16,6 @@ */ import './base.fixture'; -import path from 'path'; -import util from 'util'; -import vm from 'vm'; -const {FFOX, CHROMIUM, WEBKIT, WIN, WIRE} = testOptions; - it('should select single option', async({page, server}) => { await page.goto(server.PREFIX + '/input/select.html'); await page.selectOption('select', 'blue'); diff --git a/test/page-set-content.spec.ts b/test/page-set-content.spec.ts index 12297394cf..ef888881d9 100644 --- a/test/page-set-content.spec.ts +++ b/test/page-set-content.spec.ts @@ -16,12 +16,8 @@ */ import './base.fixture'; -import path from 'path'; -import util from 'util'; -import vm from 'vm'; -const {FFOX, CHROMIUM, WEBKIT, WIN, WIRE} = testOptions; - const expectedOutput = '
hello
'; + it('should work', async({page, server}) => { await page.setContent('
hello
'); const result = await page.content(); diff --git a/test/page-set-extra-http-headers.spec.ts b/test/page-set-extra-http-headers.spec.ts index 8ebe27cc9e..144d055403 100644 --- a/test/page-set-extra-http-headers.spec.ts +++ b/test/page-set-extra-http-headers.spec.ts @@ -16,12 +16,6 @@ */ import './base.fixture'; -import fs from 'fs'; -import path from 'path'; -import utils from './utils'; -const {FFOX, CHROMIUM, WEBKIT, MAC, WIN} = testOptions; - - it('should work', async({page, server}) => { await page.setExtraHTTPHeaders({ foo: 'bar' diff --git a/test/page-wait-for-load-state.spec.ts b/test/page-wait-for-load-state.spec.ts index d6343b4216..563560757d 100644 --- a/test/page-wait-for-load-state.spec.ts +++ b/test/page-wait-for-load-state.spec.ts @@ -16,11 +16,7 @@ */ import './base.fixture'; -import utils from './utils'; -import path from 'path'; -import url from 'url'; import { Route } from '..'; -const {FFOX, CHROMIUM, WEBKIT, MAC, WIN} = testOptions; it('should pick up ongoing navigation', async({page, server}) => { let response = null; diff --git a/test/page-wait-for-navigation.spec.ts b/test/page-wait-for-navigation.spec.ts index 4ca2bfdaa6..5e8e6930d5 100644 --- a/test/page-wait-for-navigation.spec.ts +++ b/test/page-wait-for-navigation.spec.ts @@ -17,12 +17,8 @@ import './base.fixture'; import utils from './utils'; -import path from 'path'; -import url from 'url'; import { Frame } from '..'; -const {FFOX, CHROMIUM, WEBKIT, MAC, WIN} = testOptions; - it('should work', async({page, server}) => { await page.goto(server.EMPTY_PAGE); const [response] = await Promise.all([ diff --git a/test/page-wait-for-request.spec.ts b/test/page-wait-for-request.spec.ts index 88e2c0007f..41d58288c9 100644 --- a/test/page-wait-for-request.spec.ts +++ b/test/page-wait-for-request.spec.ts @@ -16,10 +16,7 @@ */ import './base.fixture'; -import path from 'path'; -import util from 'util'; import vm from 'vm'; -const {FFOX, CHROMIUM, WEBKIT, WIN, WIRE} = testOptions; it('should work', async({page, server}) => { await page.goto(server.EMPTY_PAGE); diff --git a/test/page-wait-for-response.spec.ts b/test/page-wait-for-response.spec.ts index 68351a21c3..6f8a249f28 100644 --- a/test/page-wait-for-response.spec.ts +++ b/test/page-wait-for-response.spec.ts @@ -16,11 +16,6 @@ */ import './base.fixture'; -import path from 'path'; -import util from 'util'; -import vm from 'vm'; -const {FFOX, CHROMIUM, WEBKIT, WIN, WIRE} = testOptions; - it('should work', async({page, server}) => { await page.goto(server.EMPTY_PAGE); const [response] = await Promise.all([ diff --git a/test/pdf.spec.ts b/test/pdf.spec.ts index d458a19399..47dfca136c 100644 --- a/test/pdf.spec.ts +++ b/test/pdf.spec.ts @@ -18,7 +18,7 @@ import './base.fixture'; import fs from 'fs' import path from 'path' -const {FFOX, CHROMIUM, WEBKIT, HEADLESS} = testOptions; +const { HEADLESS } = testOptions; // Printing to pdf is currently only supported in headless chromium. it.skip(!(HEADLESS && CHROMIUM))('should be able to save file', async({page, tmpDir}) => { diff --git a/test/permissions.spec.ts b/test/permissions.spec.ts index 455941d9d6..d2864eea45 100644 --- a/test/permissions.spec.ts +++ b/test/permissions.spec.ts @@ -15,8 +15,7 @@ * limitations under the License. */ import './base.fixture'; - -const {FFOX, CHROMIUM, WEBKIT, LINUX, HEADLESS} = testOptions; +const { HEADLESS } = testOptions; function getPermission(page, name) { return page.evaluate(name => navigator.permissions.query({name}).then(result => result.state), name); diff --git a/test/popup.spec.ts b/test/popup.spec.ts index 6b7d49e39f..3efd35a6e3 100644 --- a/test/popup.spec.ts +++ b/test/popup.spec.ts @@ -15,9 +15,6 @@ */ import './base.fixture'; -const {FFOX, CHROMIUM, WEBKIT, MAC} = testOptions; - - it('should inherit user agent from browser context', async function({browser, server}) { const context = await browser.newContext({ userAgent: 'hey' diff --git a/test/proxy.spec.ts b/test/proxy.spec.ts index 61a4321b13..e4999be8ff 100644 --- a/test/proxy.spec.ts +++ b/test/proxy.spec.ts @@ -16,8 +16,8 @@ import './base.fixture'; import socks from 'socksv5'; -import utils from './utils'; -const {FFOX, CHROMIUM, WEBKIT, MAC, HEADLESS} = testOptions; + +const { HEADLESS } = testOptions; it('should use proxy', async ({browserType, defaultBrowserOptions, server}) => { server.setRoute('/target.html', async (req, res) => { diff --git a/test/queryselector.spec.ts b/test/queryselector.spec.ts index 28d04bd60f..7d9dbc19fb 100644 --- a/test/queryselector.spec.ts +++ b/test/queryselector.spec.ts @@ -16,10 +16,6 @@ */ import './base.fixture'; -import path from 'path'; -import utils from './utils'; -const {FFOX, CHROMIUM, WEBKIT, WIRE} = testOptions; - it('should query existing element with css selector', async({page, server}) => { await page.setContent('
test
'); const element = await page.$('css=section'); diff --git a/test/request-continue.spec.ts b/test/request-continue.spec.ts index e032b461f7..b2f4d8351a 100644 --- a/test/request-continue.spec.ts +++ b/test/request-continue.spec.ts @@ -16,12 +16,6 @@ */ import './base.fixture'; -import fs from 'fs'; -import path from 'path'; -import { helper } from '../lib/helper'; -import vm from 'vm'; -const {FFOX, CHROMIUM, WEBKIT, HEADLESS} = testOptions; - it('should work', async({page, server}) => { await page.route('**/*', route => route.continue()); await page.goto(server.EMPTY_PAGE); diff --git a/test/request-fulfill.spec.ts b/test/request-fulfill.spec.ts index 1b0305fd95..e87dd280eb 100644 --- a/test/request-fulfill.spec.ts +++ b/test/request-fulfill.spec.ts @@ -18,9 +18,8 @@ import './base.fixture'; import fs from 'fs'; import path from 'path'; -import { helper } from '../lib/helper'; -import vm from 'vm'; -const {FFOX, CHROMIUM, WEBKIT, HEADLESS} = testOptions; + +const { HEADLESS } = testOptions; it('should work', async({page, server}) => { await page.route('**/*', route => { diff --git a/test/runner/testOptions.js b/test/runner/testOptions.js index 06eadaebe1..3215748b51 100644 --- a/test/runner/testOptions.js +++ b/test/runner/testOptions.js @@ -15,19 +15,9 @@ */ const os = require('os'); -const path = require('path'); const { valueFromEnv } = require('./utils'); -const platform = process.env.REPORT_ONLY_PLATFORM || os.platform(); -const browserName = process.env.BROWSER || 'chromium'; - const testOptions = {}; -testOptions.MAC = platform === 'darwin'; -testOptions.LINUX = platform === 'linux'; -testOptions.WIN = platform === 'win32'; -testOptions.CHROMIUM = browserName === 'chromium'; -testOptions.FFOX = browserName === 'firefox'; -testOptions.WEBKIT = browserName === 'webkit'; testOptions.WIRE = process.env.PWWIRE; testOptions.HEADLESS = !!valueFromEnv('HEADLESS', true); diff --git a/test/screencast.spec.ts b/test/screencast.spec.ts index cc959d0704..6bffb979cb 100644 --- a/test/screencast.spec.ts +++ b/test/screencast.spec.ts @@ -17,11 +17,11 @@ import './base.fixture'; import { registerFixture } from './runner/fixtures'; import { Page } from '..'; -const fs = require('fs'); -const path = require('path'); -const url = require('url'); +import fs from 'fs'; +import path from 'path'; +import url from 'url'; -const {FFOX, CHROMIUM, WEBKIT, MAC, LINUX, WIN, HEADLESS, WIRE} = testOptions; +const { HEADLESS } = testOptions; declare global { interface FixtureState { diff --git a/test/selectors-css.spec.ts b/test/selectors-css.spec.ts index 30ff99e60d..178122ef6a 100644 --- a/test/selectors-css.spec.ts +++ b/test/selectors-css.spec.ts @@ -16,10 +16,6 @@ */ import './base.fixture'; -import path from 'path'; -import utils from './utils'; -const {FFOX, CHROMIUM, WEBKIT, WIRE} = testOptions; - it('should work for open shadow roots', async({page, server}) => { await page.goto(server.PREFIX + '/deep-shadow.html'); expect(await page.$eval(`css=span`, e => e.textContent)).toBe('Hello from root1'); diff --git a/test/selectors-misc.spec.ts b/test/selectors-misc.spec.ts index cafca65995..8a76a61f5d 100644 --- a/test/selectors-misc.spec.ts +++ b/test/selectors-misc.spec.ts @@ -16,10 +16,6 @@ */ import './base.fixture'; -import path from 'path'; -import utils from './utils'; -const {FFOX, CHROMIUM, WEBKIT, WIRE} = testOptions; - it('should work for open shadow roots', async({page, server}) => { await page.goto(server.PREFIX + '/deep-shadow.html'); expect(await page.$eval(`id=target`, e => e.textContent)).toBe('Hello from root2'); diff --git a/test/selectors-register.spec.ts b/test/selectors-register.spec.ts index 8019c561fd..0a47cff677 100644 --- a/test/selectors-register.spec.ts +++ b/test/selectors-register.spec.ts @@ -18,7 +18,6 @@ import './base.fixture'; import path from 'path'; import utils from './utils'; -const {FFOX, CHROMIUM, WEBKIT, WIRE} = testOptions; it('should work', async ({playwright, page}) => { const createTagSelector = () => ({ diff --git a/test/selectors-text.spec.ts b/test/selectors-text.spec.ts index 470cf410d1..c3620df09e 100644 --- a/test/selectors-text.spec.ts +++ b/test/selectors-text.spec.ts @@ -16,10 +16,6 @@ */ import './base.fixture'; -import path from 'path'; -import utils from './utils'; -const {FFOX, CHROMIUM, WEBKIT, WIRE} = testOptions; - it('query', async ({page}) => { await page.setContent(`
yo
ya
\nye
`); expect(await page.$eval(`text=ya`, e => e.outerHTML)).toBe('
ya
'); diff --git a/test/types.d.ts b/test/types.d.ts index d947ede174..0398334ba2 100644 --- a/test/types.d.ts +++ b/test/types.d.ts @@ -24,10 +24,8 @@ declare module '' { } } - declare const expect: typeof import('expect'); - declare const describe: DescribeFunction; declare const fdescribe: DescribeFunction; declare const xdescribe: DescribeFunction; @@ -45,17 +43,16 @@ declare const browserType: import('../index').BrowserType { +it('should timeout', async({page}) => { const startTime = Date.now(); const timeout = 42; await page.waitForTimeout(timeout); expect(Date.now() - startTime).not.toBeLessThan(timeout / 2); }); -it('should accept a string', async({page, server}) => { +it('should accept a string', async({page}) => { const watchdog = page.waitForFunction('window.__FOO === 1'); await page.evaluate(() => window['__FOO'] = 1); await watchdog; }); -it('should work when resolved right before execution context disposal', async({page, server}) => { +it('should work when resolved right before execution context disposal', async({page}) => { await page.addInitScript(() => window['__RELOADED'] = true); await page.waitForFunction(() => { if (!window['__RELOADED']) @@ -53,7 +50,7 @@ it('should poll on interval', async({page, server}) => { expect(await timeDelta.jsonValue()).not.toBeLessThan(polling); }); -it('should avoid side effects after timeout', async({page, server}) => { +it('should avoid side effects after timeout', async({page}) => { let counter = 0; page.on('console', () => ++counter); @@ -69,23 +66,23 @@ it('should avoid side effects after timeout', async({page, server}) => { expect(counter).toBe(savedCounter); }); -it('should throw on polling:mutation', async({page, server}) => { +it('should throw on polling:mutation', async({page}) => { const error = await page.waitForFunction(() => true, {}, {polling: 'mutation' as any}).catch(e => e); expect(error.message).toContain('Unknown polling option: mutation'); }); -it('should poll on raf', async({page, server}) => { +it('should poll on raf', async({page}) => { const watchdog = page.waitForFunction(() => window['__FOO'] === 'hit', {}, {polling: 'raf'}); await page.evaluate(() => window['__FOO'] = 'hit'); await watchdog; }); -it('should fail with predicate throwing on first call', async({page, server}) => { +it('should fail with predicate throwing on first call', async({page}) => { const error = await page.waitForFunction(() => { throw new Error('oh my'); }).catch(e => e); expect(error.message).toContain('oh my'); }); -it('should fail with predicate throwing sometimes', async({page, server}) => { +it('should fail with predicate throwing sometimes', async({page}) => { const error = await page.waitForFunction(() => { window['counter'] = (window['counter'] || 0) + 1; if (window['counter'] === 3) @@ -95,7 +92,7 @@ it('should fail with predicate throwing sometimes', async({page, server}) => { expect(error.message).toContain('Bad counter!'); }); -it('should fail with ReferenceError on wrong page', async({page, server}) => { +it('should fail with ReferenceError on wrong page', async({page}) => { // @ts-ignore const error = await page.waitForFunction(() => globalVar === 123).catch(e => e); expect(error.message).toContain('globalVar'); @@ -112,7 +109,7 @@ it('should work with strict CSP policy', async({page, server}) => { expect(error).toBe(null); }); -it('should throw on bad polling value', async({page, server}) => { +it('should throw on bad polling value', async({page}) => { let error = null; try { await page.waitForFunction(() => !!document.body, {}, {polling: 'unknown' as any}); @@ -123,7 +120,7 @@ it('should throw on bad polling value', async({page, server}) => { expect(error.message).toContain('polling'); }); -it('should throw negative polling interval', async({page, server}) => { +it('should throw negative polling interval', async({page}) => { let error = null; try { await page.waitForFunction(() => !!document.body, {}, {polling: -10}); @@ -200,13 +197,13 @@ it('should survive navigations', async({page, server}) => { await watchdog; }); -it('should work with multiline body', async({page, server}) => { +it('should work with multiline body', async({page}) => { const result = await page.waitForFunction(` (() => true)() `); expect(await result.jsonValue()).toBe(true); }); -it('should wait for predicate with arguments', async({page, server}) => { +it('should wait for predicate with arguments', async({page}) => { await page.waitForFunction(({arg1, arg2}) => arg1 + arg2 === 3, { arg1: 1, arg2: 2}); }); diff --git a/test/wait-for-selector.spec.ts b/test/wait-for-selector.spec.ts index 83e720afc4..d6f2d56e5a 100644 --- a/test/wait-for-selector.spec.ts +++ b/test/wait-for-selector.spec.ts @@ -14,10 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import './base.fixture'; +import './base.fixture'; import utils from './utils'; -const {FFOX, CHROMIUM, WEBKIT} = testOptions; async function giveItTimeToLog(frame) { await frame.evaluate(() => new Promise(f => requestAnimationFrame(() => requestAnimationFrame(f)))); @@ -25,6 +24,7 @@ async function giveItTimeToLog(frame) { } const addElement = tag => document.body.appendChild(document.createElement(tag)); + it('should throw on waitFor', async({page, server}) => { await page.goto(server.EMPTY_PAGE); let error; diff --git a/test/workers.spec.ts b/test/workers.spec.ts index ce195c06e8..0fcf71e773 100644 --- a/test/workers.spec.ts +++ b/test/workers.spec.ts @@ -14,11 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + import './base.fixture'; import { ConsoleMessage } from '..'; -const {FFOX, CHROMIUM, WEBKIT} = testOptions; - it('Page.workers', async function({page, server}) { await Promise.all([ page.waitForEvent('worker'),