chore(test): require playwright fixtures from userland (#3355)
This patch moves fixtures.js to base.fixtures.ts that sits next to tests. All tests get an extra import to get the base fixtures (both types and implementations).
This commit is contained in:
parent
82c6843c60
commit
d76166beca
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
require('./base.fixture');
|
||||
|
||||
const {FFOX, CHROMIUM, WEBKIT} = testOptions;
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import './base.fixture';
|
||||
|
||||
import utils from './utils';
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import './base.fixture';
|
||||
|
||||
import utils from './utils';
|
||||
|
||||
|
|
|
|||
181
test/base.fixture.ts
Normal file
181
test/base.fixture.ts
Normal file
|
|
@ -0,0 +1,181 @@
|
|||
/**
|
||||
* Copyright Microsoft Corporation. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
import childProcess from 'child_process';
|
||||
import { LaunchOptions, BrowserType, Browser, BrowserContext, Page, BrowserServer } from '../index';
|
||||
import { TestServer } from '../utils/testserver/';
|
||||
import { Connection } from '../lib/rpc/client/connection';
|
||||
import { Transport } from '../lib/rpc/transport';
|
||||
import { setUnderTest } from '../lib/helper';
|
||||
import { installCoverageHooks } from './harness/coverage';
|
||||
import { valueFromEnv } from './harness/utils';
|
||||
|
||||
setUnderTest(); // Note: we must call setUnderTest before requiring Playwright
|
||||
|
||||
const browserName = process.env.BROWSER || 'chromium';
|
||||
|
||||
declare global {
|
||||
interface WorkerState {
|
||||
parallelIndex: number;
|
||||
http_server: {server: TestServer, httpsServer: TestServer};
|
||||
defaultBrowserOptions: LaunchOptions;
|
||||
playwright: typeof import('../index');
|
||||
browserType: BrowserType<Browser>;
|
||||
browser: Browser;
|
||||
}
|
||||
interface FixtureState {
|
||||
toImpl: (rpcObject: any) => any;
|
||||
context: BrowserContext;
|
||||
server: TestServer;
|
||||
page: Page;
|
||||
httpsServer: TestServer;
|
||||
browserServer: BrowserServer;
|
||||
}
|
||||
}
|
||||
|
||||
registerWorkerFixture('parallelIndex', async ({}, test) => {
|
||||
await test(parseInt(process.env.JEST_WORKER_ID, 10) - 1);
|
||||
});
|
||||
|
||||
registerWorkerFixture('http_server', async ({parallelIndex}, test) => {
|
||||
const assetsPath = path.join(__dirname, 'assets');
|
||||
const cachedPath = path.join(__dirname, 'assets', 'cached');
|
||||
|
||||
const port = 8907 + parallelIndex * 2;
|
||||
const server = await TestServer.create(assetsPath, port);
|
||||
server.enableHTTPCache(cachedPath);
|
||||
|
||||
const httpsPort = port + 1;
|
||||
const httpsServer = await TestServer.createHTTPS(assetsPath, httpsPort);
|
||||
httpsServer.enableHTTPCache(cachedPath);
|
||||
|
||||
await test({server, httpsServer});
|
||||
|
||||
await Promise.all([
|
||||
server.stop(),
|
||||
httpsServer.stop(),
|
||||
]);
|
||||
});
|
||||
|
||||
registerWorkerFixture('defaultBrowserOptions', async({}, test) => {
|
||||
let executablePath = undefined;
|
||||
if (browserName === 'chromium' && process.env.CRPATH)
|
||||
executablePath = process.env.CRPATH;
|
||||
if (browserName === 'firefox' && process.env.FFPATH)
|
||||
executablePath = process.env.FFPATH;
|
||||
if (browserName === 'webkit' && process.env.WKPATH)
|
||||
executablePath = process.env.WKPATH;
|
||||
if (executablePath)
|
||||
console.error(`Using executable at ${executablePath}`);
|
||||
await test({
|
||||
handleSIGINT: false,
|
||||
slowMo: valueFromEnv('SLOW_MO', 0),
|
||||
headless: !!valueFromEnv('HEADLESS', true),
|
||||
executablePath
|
||||
});
|
||||
});
|
||||
|
||||
registerWorkerFixture('playwright', async({}, test) => {
|
||||
const {coverage, uninstall} = installCoverageHooks(browserName);
|
||||
if (process.env.PWCHANNEL === 'wire') {
|
||||
const connection = new Connection();
|
||||
const spawnedProcess = childProcess.fork(path.join(__dirname, '..', 'lib', 'rpc', 'server'), [], {
|
||||
stdio: 'pipe',
|
||||
detached: true,
|
||||
});
|
||||
spawnedProcess.unref();
|
||||
const onExit = (exitCode, signal) => {
|
||||
throw new Error(`Server closed with exitCode=${exitCode} signal=${signal}`);
|
||||
};
|
||||
spawnedProcess.on('exit', onExit);
|
||||
const transport = new Transport(spawnedProcess.stdin, spawnedProcess.stdout);
|
||||
connection.onmessage = message => transport.send(JSON.stringify(message));
|
||||
transport.onmessage = message => connection.dispatch(JSON.parse(message));
|
||||
const playwrightObject = await connection.waitForObjectWithKnownName('Playwright');
|
||||
try {
|
||||
await test(playwrightObject);
|
||||
} finally {
|
||||
spawnedProcess.removeListener('exit', onExit);
|
||||
spawnedProcess.stdin.destroy();
|
||||
spawnedProcess.stdout.destroy();
|
||||
spawnedProcess.stderr.destroy();
|
||||
await teardownCoverage();
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
await test(require('../index'))
|
||||
} finally {
|
||||
await teardownCoverage();
|
||||
}
|
||||
}
|
||||
|
||||
async function teardownCoverage() {
|
||||
uninstall();
|
||||
const relativeTestPath = path.relative(__dirname, testPath);
|
||||
const coveragePath = path.join(path.join(__dirname, 'output-' + browserName), 'coverage', relativeTestPath + '.json');
|
||||
const coverageJSON = [...coverage.keys()].filter(key => coverage.get(key));
|
||||
await fs.promises.mkdir(path.dirname(coveragePath), { recursive: true });
|
||||
await fs.promises.writeFile(coveragePath, JSON.stringify(coverageJSON, undefined, 2), 'utf8');
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
registerFixture('toImpl', async ({playwright}, test) => {
|
||||
await test((playwright as any)._toImpl);
|
||||
});
|
||||
|
||||
registerWorkerFixture('browserType', async ({playwright}, test) => {
|
||||
await test(playwright[process.env.BROWSER || 'chromium']);
|
||||
});
|
||||
|
||||
registerWorkerFixture('browser', async ({browserType, defaultBrowserOptions}, test) => {
|
||||
const browser = await browserType.launch(defaultBrowserOptions);
|
||||
try {
|
||||
await test(browser);
|
||||
if (browser.contexts().length !== 0) {
|
||||
console.warn(`\nWARNING: test did not close all created contexts! ${new Error().stack}\n`);
|
||||
await Promise.all(browser.contexts().map(context => context.close()));
|
||||
}
|
||||
} finally {
|
||||
await browser.close();
|
||||
}
|
||||
});
|
||||
|
||||
registerFixture('context', async ({browser}, test) => {
|
||||
const context = await browser.newContext();
|
||||
try {
|
||||
await test(context);
|
||||
} finally {
|
||||
await context.close();
|
||||
}
|
||||
});
|
||||
|
||||
registerFixture('page', async ({context}, test) => {
|
||||
const page = await context.newPage();
|
||||
await test(page);
|
||||
});
|
||||
|
||||
registerFixture('server', async ({http_server}, test) => {
|
||||
http_server.server.reset();
|
||||
await test(http_server.server);
|
||||
});
|
||||
|
||||
registerFixture('httpsServer', async ({http_server}, test) => {
|
||||
http_server.httpsServer.reset();
|
||||
await test(http_server.httpsServer);
|
||||
});
|
||||
|
|
@ -13,6 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import './base.fixture';
|
||||
|
||||
import utils from './utils';
|
||||
const {CHROMIUM} = testOptions;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import './base.fixture';
|
||||
|
||||
import utils from './utils';
|
||||
const {FFOX, CHROMIUM} = testOptions;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import './base.fixture';
|
||||
|
||||
import utils from './utils';
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import './base.fixture';
|
||||
|
||||
import utils from './utils';
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import './base.fixture';
|
||||
|
||||
import utils from './utils';
|
||||
const {FFOX, WEBKIT, WIN} = testOptions;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import './base.fixture';
|
||||
|
||||
import utils from './utils';
|
||||
const {CHROMIUM, HEADLESS} = testOptions;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import './base.fixture';
|
||||
|
||||
import * as utils from './utils';
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import './base.fixture';
|
||||
|
||||
import utils from './utils';
|
||||
const {FFOX} = testOptions;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import './base.fixture';
|
||||
|
||||
import utils from './utils';
|
||||
const {FFOX, CHROMIUM, WEBKIT, MAC, CHANNEL, HEADLESS} = testOptions;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import './base.fixture';
|
||||
|
||||
import utils from './utils';
|
||||
const {CHROMIUM, FFOX, MAC, HEADLESS} = testOptions;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import './base.fixture';
|
||||
import utils from './utils';
|
||||
const {FFOX, CHROMIUM, WEBKIT, MAC, CHANNEL, HEADLESS} = testOptions;
|
||||
const {devices} = require('..');
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import './base.fixture';
|
||||
|
||||
import utils from './utils';
|
||||
const {FFOX, CHROMIUM, WEBKIT, MAC, CHANNEL, HEADLESS} = testOptions;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import './base.fixture';
|
||||
|
||||
import utils from './utils';
|
||||
const {CHROMIUM, FFOX, MAC, HEADLESS} = testOptions;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import './base.fixture';
|
||||
|
||||
import utils from './utils';
|
||||
const {FFOX, CHROMIUM, WEBKIT, MAC, CHANNEL, HEADLESS} = testOptions;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import './base.fixture';
|
||||
|
||||
import utils from './utils';
|
||||
const {CHROMIUM, FFOX, MAC, HEADLESS} = testOptions;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import './base.fixture';
|
||||
|
||||
import utils from './utils';
|
||||
const {CHROMIUM, FFOX, MAC, HEADLESS} = testOptions;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* 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';
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import './base.fixture';
|
||||
|
||||
import utils from './utils';
|
||||
const {FFOX, CHROMIUM, WEBKIT, WIN, USES_HOOKS, CHANNEL} = testOptions;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
require('./base.fixture');
|
||||
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* 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';
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
* 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';
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import './base.fixture';
|
||||
|
||||
import utils from './utils';
|
||||
import { ChromiumBrowser } from '../types/types';
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import './base.fixture';
|
||||
|
||||
it('should check the box', async({page}) => {
|
||||
await page.setContent(`<input id='checkbox' type='checkbox'></input>`);
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import './base.fixture';
|
||||
|
||||
import utils from './utils';
|
||||
const {FFOX, CHROMIUM, WEBKIT} = testOptions;
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import './base.fixture';
|
||||
|
||||
import utils from './utils';
|
||||
const {FFOX, CHROMIUM, WEBKIT} = testOptions;
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
require('../base.fixture');
|
||||
|
||||
const {FFOX, CHROMIUM, WEBKIT, CHANNEL} = testOptions;
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
require('../base.fixture');
|
||||
|
||||
const path = require('path');
|
||||
const utils = require('../utils');
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import '../base.fixture';
|
||||
import { Page, Browser, BrowserContext } from '../../types/types';
|
||||
|
||||
const {FFOX, CHROMIUM, WEBKIT, CHANNEL} = testOptions;
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
require('../base.fixture');
|
||||
|
||||
const {FFOX, CHROMIUM, WEBKIT, CHANNEL, USES_HOOKS} = testOptions;
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import '../base.fixture';
|
||||
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import './base.fixture';
|
||||
import utils from './utils';
|
||||
|
||||
declare const renderComponent;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import './base.fixture';
|
||||
|
||||
import utils from './utils';
|
||||
const {USES_HOOKS} = testOptions;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import './base.fixture';
|
||||
|
||||
import utils from './utils';
|
||||
const {USES_HOOKS} = testOptions;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import './base.fixture';
|
||||
|
||||
import utils from './utils';
|
||||
const {USES_HOOKS} = testOptions;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import './base.fixture';
|
||||
import utils from './utils';
|
||||
|
||||
it('should timeout waiting for stable position', async({page, server}) => {
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import './base.fixture';
|
||||
|
||||
import utils from './utils';
|
||||
const {FFOX, CHROMIUM, WEBKIT, HEADLESS, USES_HOOKS} = testOptions;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import './base.fixture';
|
||||
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
require('./base.fixture');
|
||||
|
||||
const {FFOX, CHROMIUM, WEBKIT, CHANNEL} = testOptions;
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
require('./base.fixture');
|
||||
|
||||
const utils = require('./utils');
|
||||
const {FFOX, CHROMIUM, WEBKIT, WIN, USES_HOOKS} = testOptions;
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import './base.fixture';
|
||||
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
* 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';
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
require('../base.fixture');
|
||||
|
||||
const path = require('path');
|
||||
const electronName = process.platform === 'win32' ? 'electron.cmd' : 'electron';
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
require('../base.fixture');
|
||||
|
||||
const path = require('path');
|
||||
const electronName = process.platform === 'win32' ? 'electron.cmd' : 'electron';
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
require('./base.fixture');
|
||||
|
||||
const utils = require('./utils');
|
||||
const { FFOX, HEADLESS } = testOptions;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
require('./base.fixture');
|
||||
|
||||
const utils = require('./utils');
|
||||
const { FFOX, HEADLESS } = testOptions;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
require('./base.fixture');
|
||||
|
||||
const utils = require('./utils');
|
||||
const { FFOX, HEADLESS } = testOptions;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
require('./base.fixture');
|
||||
|
||||
const utils = require('./utils');
|
||||
const { FFOX, HEADLESS } = testOptions;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
require('./base.fixture');
|
||||
|
||||
const path = require('path');
|
||||
const utils = require('./utils');
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
require('./base.fixture');
|
||||
|
||||
const utils = require('./utils');
|
||||
const { FFOX, HEADLESS } = testOptions;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
require('./base.fixture');
|
||||
|
||||
const utils = require('./utils');
|
||||
const { FFOX, HEADLESS } = testOptions;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
require('./base.fixture');
|
||||
|
||||
const utils = require('./utils');
|
||||
const { FFOX, HEADLESS } = testOptions;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
require('./base.fixture');
|
||||
|
||||
const path = require('path');
|
||||
const utils = require('./utils');
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
require('./base.fixture');
|
||||
|
||||
const utils = require('./utils');
|
||||
const {FFOX, CHROMIUM, WEBKIT, USES_HOOKS, HEADLESS} = testOptions;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
require('./base.fixture');
|
||||
|
||||
const utils = require('./utils');
|
||||
const { FFOX, HEADLESS } = testOptions;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
require('./base.fixture');
|
||||
|
||||
const utils = require('./utils');
|
||||
const { FFOX, HEADLESS } = testOptions;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
require('./base.fixture');
|
||||
|
||||
const utils = require('./utils');
|
||||
const { FFOX, HEADLESS } = testOptions;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
require('./base.fixture');
|
||||
|
||||
const utils = require('./utils');
|
||||
const {CHROMIUM, FFOX, MAC, HEADLESS} = testOptions;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
require('./base.fixture');
|
||||
|
||||
const path = require('path');
|
||||
const utils = require('./utils');
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
require('./base.fixture');
|
||||
|
||||
const path = require('path');
|
||||
const utils = require('./utils');
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
require('../base.fixture');
|
||||
|
||||
const { FFOX } = testOptions;
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import './base.fixture';
|
||||
|
||||
import path from 'path';
|
||||
import {spawn, execSync} from 'child_process';
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
require('./base.fixture');
|
||||
|
||||
const {FFOX, CHROMIUM, LINUX, WEBKIT, MAC} = testOptions;
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
require('./base.fixture');
|
||||
|
||||
const utils = require('./utils');
|
||||
const path = require('path');
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
require('./base.fixture');
|
||||
|
||||
const utils = require('./utils');
|
||||
const {FFOX, CHROMIUM, WEBKIT} = testOptions;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
require('./base.fixture');
|
||||
|
||||
const utils = require('./utils');
|
||||
const path = require('path');
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
require('./base.fixture');
|
||||
|
||||
const utils = require('./utils');
|
||||
const {FFOX, CHROMIUM, WEBKIT} = testOptions;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
require('./base.fixture');
|
||||
|
||||
const {FFOX, CHROMIUM, WEBKIT} = testOptions;
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
function traceAPICoverage(apiCoverage, api, events) {
|
||||
const uninstalls = [];
|
||||
for (const [name, classType] of Object.entries(api)) {
|
||||
// console.log('trace', name);
|
||||
const className = name.substring(0, 1).toLowerCase() + name.substring(1);
|
||||
for (const methodName of Reflect.ownKeys(classType.prototype)) {
|
||||
const method = Reflect.get(classType.prototype, methodName);
|
||||
|
|
@ -13,6 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
require('./base.fixture');
|
||||
|
||||
const utils = require('./utils');
|
||||
const { makeUserDataDir, removeUserDataDir } = utils;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
require('./base.fixture');
|
||||
|
||||
const {FFOX, CHROMIUM, WEBKIT, MAC} = testOptions;
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
require('./base.fixture');
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const {installCoverageHooks} = require('./coverage');
|
||||
const {installCoverageHooks} = require('../harness/coverage');
|
||||
|
||||
const browserName = process.env.BROWSER || 'chromium';
|
||||
|
||||
|
|
|
|||
|
|
@ -15,22 +15,19 @@
|
|||
*/
|
||||
|
||||
const { FixturePool, registerFixture, registerWorkerFixture } = require('../harness/fixturePool');
|
||||
const registerFixtures = require('../harness/fixtures');
|
||||
const os = require('os');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const debug = require('debug');
|
||||
const util = require('util');
|
||||
const GoldenUtils = require('../../utils/testrunner/GoldenUtils');
|
||||
const {installCoverageHooks} = require('./coverage');
|
||||
const reportOnly = !!process.env.REPORT_ONLY_PLATFORM;
|
||||
const { ModuleMocker } = require('jest-mock');
|
||||
|
||||
global.testOptions = require('../harness/testOptions');
|
||||
global.registerFixture = registerFixture;
|
||||
global.registerWorkerFixture = registerWorkerFixture;
|
||||
|
||||
registerFixtures(global);
|
||||
global.testPath = null;
|
||||
|
||||
const browserName = process.env.BROWSER || 'chromium';
|
||||
|
||||
|
|
@ -53,32 +50,16 @@ class PlaywrightEnvironment {
|
|||
this.fixturePool = new FixturePool();
|
||||
this.global = global;
|
||||
this.global.testOptions = testOptions;
|
||||
this.testPath = context.testPath;
|
||||
this.global.testPath = context.testPath;
|
||||
}
|
||||
|
||||
async setup() {
|
||||
const {coverage, uninstall} = installCoverageHooks(browserName);
|
||||
this.coverage = coverage;
|
||||
this.uninstallCoverage = uninstall;
|
||||
currentFixturePool = this.fixturePool;
|
||||
}
|
||||
|
||||
async teardown() {
|
||||
currentFixturePool = null;
|
||||
await this.fixturePool.teardownScope('worker');
|
||||
// If the setup throws an error, we don't want to override it
|
||||
// with a useless error about this.coverage not existing.
|
||||
if (!this.coverage)
|
||||
return;
|
||||
this.uninstallCoverage();
|
||||
const testRoot = path.join(__dirname, '..');
|
||||
const relativeTestPath = path.relative(testRoot, this.testPath);
|
||||
const coveragePath = path.join(outputPath, 'coverage', relativeTestPath + '.json');
|
||||
const coverageJSON = [...this.coverage.keys()].filter(key => this.coverage.get(key));
|
||||
await fs.promises.mkdir(path.dirname(coveragePath), { recursive: true });
|
||||
await fs.promises.writeFile(coveragePath, JSON.stringify(coverageJSON, undefined, 2), 'utf8');
|
||||
delete this.coverage;
|
||||
delete this.uninstallCoverage;
|
||||
}
|
||||
|
||||
runScript(script) {
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
require('./base.fixture');
|
||||
|
||||
const {FFOX, CHROMIUM, WEBKIT} = testOptions;
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
require('./base.fixture');
|
||||
|
||||
const {FFOX, CHROMIUM, WEBKIT} = testOptions;
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
require('./base.fixture');
|
||||
|
||||
const {FFOX, CHROMIUM, WEBKIT} = testOptions;
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
require('./base.fixture');
|
||||
|
||||
const {FFOX, CHROMIUM, WEBKIT} = testOptions;
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
require('./base.fixture');
|
||||
|
||||
const {FFOX, CHROMIUM, WEBKIT} = testOptions;
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
require('./base.fixture');
|
||||
|
||||
const utils = require('./utils');
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
require('./base.fixture');
|
||||
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
require('./base.fixture');
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
require('./base.fixture');
|
||||
|
||||
const {FFOX, CHROMIUM, WEBKIT, MAC, WIN} = testOptions;
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
require('./base.fixture');
|
||||
|
||||
const {FFOX, CHROMIUM, WEBKIT} = testOptions;
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
require('./base.fixture');
|
||||
|
||||
it('should work with _blank target', async({page, server}) => {
|
||||
server.setRoute('/empty.html', (req, res) => {
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
require('./base.fixture');
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
require('./base.fixture');
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
|
|
|||
|
|
@ -22,14 +22,12 @@ const pirates = require('pirates');
|
|||
const babel = require('@babel/core');
|
||||
const TestRunner = require('../../utils/testrunner');
|
||||
const { FixturePool, registerFixture, registerWorkerFixture } = require('../harness/fixturePool');
|
||||
const registerFixtures = require('../harness/fixtures');
|
||||
const testOptions = require('../harness/testOptions');
|
||||
|
||||
Error.stackTraceLimit = 15;
|
||||
global.testOptions = require('../harness/testOptions');
|
||||
global.registerFixture = registerFixture;
|
||||
global.registerWorkerFixture = registerWorkerFixture;
|
||||
registerFixtures(global);
|
||||
process.env.JEST_WORKER_ID = 1;
|
||||
const browserName = process.env.BROWSER || 'chromium';
|
||||
const goldenPath = path.join(__dirname, '..', 'golden-' + browserName);
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
require('./base.fixture');
|
||||
|
||||
const utils = require('./utils');
|
||||
const path = require('path');
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
require('./base.fixture');
|
||||
|
||||
const path = require('path');
|
||||
const util = require('util');
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
require('./base.fixture');
|
||||
|
||||
const path = require('path');
|
||||
const util = require('util');
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
require('./base.fixture');
|
||||
|
||||
const path = require('path');
|
||||
const util = require('util');
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
require('./base.fixture');
|
||||
|
||||
const utils = require('./utils');
|
||||
const {CHROMIUM, FFOX, MAC, HEADLESS} = testOptions;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
require('./base.fixture');
|
||||
|
||||
const {FFOX, CHROMIUM, WEBKIT} = testOptions;
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
require('./base.fixture');
|
||||
|
||||
const utils = require('./utils');
|
||||
const path = require('path');
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
require('./base.fixture');
|
||||
|
||||
const path = require('path');
|
||||
const util = require('util');
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
require('./base.fixture');
|
||||
|
||||
const path = require('path');
|
||||
const util = require('util');
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue