Skip to content

Commit

Permalink
test: slowly removing testOptions (#3464)
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelfeldman authored Aug 14, 2020
1 parent 036cd5c commit 2f5a0a6
Show file tree
Hide file tree
Showing 128 changed files with 130 additions and 437 deletions.
2 changes: 2 additions & 0 deletions docs/test-runners.md
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down
2 changes: 0 additions & 2 deletions test/accessibility.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
*/
import './base.fixture';

const {FFOX, CHROMIUM, WEBKIT} = testOptions;

it('should work', async function({page}) {
await page.setContent(`
<head>
Expand Down
5 changes: 1 addition & 4 deletions test/autowaiting-basic.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand Down
2 changes: 0 additions & 2 deletions test/autowaiting-no-hang.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(`<a href='${httpsServer.EMPTY_PAGE}'>foobar</a>`);
Expand Down
10 changes: 9 additions & 1 deletion test/base.fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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);
});
Expand Down Expand Up @@ -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) => {
Expand Down
1 change: 0 additions & 1 deletion test/browser.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 0 additions & 3 deletions test/browsercontext-add-cookies.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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([{
Expand Down
2 changes: 0 additions & 2 deletions test/browsercontext-basic.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 0 additions & 3 deletions test/browsercontext-cookies.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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([]);
});
Expand Down
3 changes: 1 addition & 2 deletions test/browsercontext-credentials.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
3 changes: 0 additions & 3 deletions test/browsercontext-device.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down
4 changes: 0 additions & 4 deletions test/browsercontext-expose-function.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 0 additions & 3 deletions test/browsercontext-locale.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 0 additions & 3 deletions test/browsercontext-page-event.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 0 additions & 4 deletions test/browsercontext-route.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 0 additions & 3 deletions test/browsercontext-timezone-id.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
{
Expand Down
1 change: 0 additions & 1 deletion test/browsercontext-user-agent.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}) => {
Expand Down
3 changes: 0 additions & 3 deletions test/browsercontext-viewport-mobile.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down
1 change: 0 additions & 1 deletion test/browsercontext-viewport.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 1 addition & 4 deletions test/browsertype-basic.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 1 addition & 2 deletions test/browsertype-connect.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 1 addition & 4 deletions test/browsertype-launch-server.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 3 additions & 4 deletions test/browsertype-launch.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 1 addition & 4 deletions test/capabilities.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
3 changes: 0 additions & 3 deletions test/channels.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 0 additions & 3 deletions test/chromium-css-coverage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
3 changes: 0 additions & 3 deletions test/chromium-js-coverage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down
2 changes: 0 additions & 2 deletions test/chromium/chromium.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
4 changes: 2 additions & 2 deletions test/chromium/launcher.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 0 additions & 2 deletions test/chromium/oopif.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 0 additions & 2 deletions test/chromium/session.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
3 changes: 2 additions & 1 deletion test/chromium/tracing.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion test/click-react.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
* limitations under the License.
*/
import './base.fixture';
import utils from './utils';

declare const renderComponent;
declare const e;
Expand Down
3 changes: 1 addition & 2 deletions test/click-timeout-1.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
3 changes: 0 additions & 3 deletions test/click-timeout-2.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
3 changes: 1 addition & 2 deletions test/click-timeout-3.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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('<button>Click me</button>');
Expand Down
Loading

0 comments on commit 2f5a0a6

Please sign in to comment.