test: remove module.export.describe wrapper (#1716)
This commit is contained in:
parent
2ef8e26602
commit
ade9d23c28
|
|
@ -15,10 +15,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @type {PageTestSuite}
|
||||
*/
|
||||
module.exports.describe = function({FFOX, CHROMIUM, WEBKIT, MAC}) {
|
||||
const {FFOX, CHROMIUM, WEBKIT} = require('./utils').testOptions(browserType);
|
||||
|
||||
describe('Accessibility', function() {
|
||||
it('should work', async function({page}) {
|
||||
|
|
@ -351,4 +348,3 @@ module.exports.describe = function({FFOX, CHROMIUM, WEBKIT, MAC}) {
|
|||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -48,8 +48,7 @@ function traceAPICoverage(apiCoverage, events, className, classType) {
|
|||
}
|
||||
}
|
||||
|
||||
module.exports.describe = function({browserType}) {
|
||||
describe('**API COVERAGE**', () => {
|
||||
describe.skip(!process.env.COVERAGE)('**API COVERAGE**', () => {
|
||||
const BROWSER_CONFIGS = [
|
||||
{
|
||||
name: 'Firefox',
|
||||
|
|
@ -100,4 +99,3 @@ module.exports.describe = function({browserType}) {
|
|||
throw new Error('Certain API Methods are not called: ' + missingMethods.join(', '));
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -15,10 +15,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @type {PageTestSuite}
|
||||
*/
|
||||
module.exports.describe = function({playwright, MAC, WIN, FFOX, CHROMIUM, WEBKIT}) {
|
||||
const {FFOX, CHROMIUM, WEBKIT} = require('./utils').testOptions(browserType);
|
||||
|
||||
describe('Auto waiting', () => {
|
||||
it('should await navigation when clicking anchor', async({page, server}) => {
|
||||
|
|
@ -226,5 +223,4 @@ module.exports.describe = function({playwright, MAC, WIN, FFOX, CHROMIUM, WEBKIT
|
|||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -14,10 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @type {BrowserTestSuite}
|
||||
*/
|
||||
module.exports.describe = function({playwright, CHROMIUM, WEBKIT}) {
|
||||
const {FFOX, CHROMIUM, WEBKIT} = require('./utils').testOptions(browserType);
|
||||
|
||||
describe('Browser.newPage', function() {
|
||||
it('should create new page', async function({browser}) {
|
||||
|
|
@ -41,4 +38,3 @@ module.exports.describe = function({playwright, CHROMIUM, WEBKIT}) {
|
|||
expect(error.message).toContain('Please use browser.newContext()');
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -16,11 +16,7 @@
|
|||
*/
|
||||
|
||||
const utils = require('./utils');
|
||||
|
||||
/**
|
||||
* @type {BrowserTestSuite}
|
||||
*/
|
||||
module.exports.describe = function({playwright, CHROMIUM, FFOX, WEBKIT, LINUX}) {
|
||||
const {FFOX, CHROMIUM, WEBKIT} = utils.testOptions(browserType);
|
||||
|
||||
describe('BrowserContext', function() {
|
||||
it('should create new context', async function({browser}) {
|
||||
|
|
@ -620,4 +616,3 @@ module.exports.describe = function({playwright, CHROMIUM, FFOX, WEBKIT, LINUX})
|
|||
await context.close();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -14,10 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @type {PageTestSuite}
|
||||
*/
|
||||
module.exports.describe = function({WIN, WEBKIT}) {
|
||||
const {FFOX, CHROMIUM, WEBKIT, WIN} = require('./utils').testOptions(browserType);
|
||||
|
||||
describe('Capabilities', function() {
|
||||
it.fail(WEBKIT && WIN)('Web Assembly should work', async function({page, server}) {
|
||||
|
|
@ -25,4 +22,3 @@ module.exports.describe = function({WIN, WEBKIT}) {
|
|||
expect(await page.evaluate(() => loadTable())).toBe('42, 83');
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -14,10 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @type {ChromiumTestSuite}
|
||||
*/
|
||||
module.exports.describe = function({playwright, FFOX, CHROMIUM, WEBKIT}) {
|
||||
const {FFOX, CHROMIUM, WEBKIT} = require('../utils').testOptions(browserType);
|
||||
|
||||
describe('ChromiumBrowserContext', function() {
|
||||
it('should create a worker from a service worker', async({browser, page, server, context}) => {
|
||||
|
|
@ -76,5 +73,3 @@ module.exports.describe = function({playwright, FFOX, CHROMIUM, WEBKIT}) {
|
|||
expect(serverRequest.headers.intervention).toContain('feature/5718547946799104');
|
||||
});
|
||||
});
|
||||
|
||||
};
|
||||
|
|
|
|||
|
|
@ -14,10 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @type {ChromiumTestSuite}
|
||||
*/
|
||||
module.exports.describe = function({FFOX, CHROMIUM, WEBKIT}) {
|
||||
const {FFOX, CHROMIUM, WEBKIT} = require('../utils').testOptions(browserType);
|
||||
|
||||
describe('JSCoverage', function() {
|
||||
it('should work', async function({page, server}) {
|
||||
|
|
@ -185,4 +182,3 @@ module.exports.describe = function({FFOX, CHROMIUM, WEBKIT}) {
|
|||
expect(coverage.length).toBe(1);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -14,16 +14,10 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
const util = require('util');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const os = require('os');
|
||||
const { makeUserDataDir, removeUserDataDir } = require('../utils');
|
||||
|
||||
/**
|
||||
* @type {TestSuite}
|
||||
*/
|
||||
module.exports.describe = function({defaultBrowserOptions, browserType, WIN}) {
|
||||
const utils = require('../utils');
|
||||
const {makeUserDataDir, removeUserDataDir} = utils;
|
||||
const {FFOX, CHROMIUM, WEBKIT, WIN, defaultBrowserOptions} = utils.testOptions(browserType);
|
||||
|
||||
const headfulOptions = Object.assign({}, defaultBrowserOptions, {
|
||||
headless: false
|
||||
|
|
@ -38,19 +32,19 @@ module.exports.describe = function({defaultBrowserOptions, browserType, WIN}) {
|
|||
});
|
||||
|
||||
describe('launcher', function() {
|
||||
it('should throw with remote-debugging-pipe argument', async() => {
|
||||
it('should throw with remote-debugging-pipe argument', async({browserType}) => {
|
||||
const options = Object.assign({}, defaultBrowserOptions);
|
||||
options.args = ['--remote-debugging-pipe'].concat(options.args || []);
|
||||
const error = await browserType.launchServer(options).catch(e => e);
|
||||
expect(error.message).toContain('Playwright manages remote debugging connection itself');
|
||||
});
|
||||
it('should throw with remote-debugging-port argument', async() => {
|
||||
it('should throw with remote-debugging-port argument', async({browserType}) => {
|
||||
const options = Object.assign({}, defaultBrowserOptions);
|
||||
options.args = ['--remote-debugging-port=9222'].concat(options.args || []);
|
||||
const error = await browserType.launchServer(options).catch(e => e);
|
||||
expect(error.message).toContain('Playwright manages remote debugging connection itself');
|
||||
});
|
||||
it('should open devtools when "devtools: true" option is given', async({server}) => {
|
||||
it('should open devtools when "devtools: true" option is given', async({browserType}) => {
|
||||
const browser = await browserType.launch(Object.assign({devtools: true}, headfulOptions));
|
||||
const context = await browser.newContext();
|
||||
const browserSession = await browser.newBrowserCDPSession();
|
||||
|
|
@ -68,7 +62,7 @@ module.exports.describe = function({defaultBrowserOptions, browserType, WIN}) {
|
|||
});
|
||||
|
||||
describe('extensions', () => {
|
||||
it('should return background pages', async() => {
|
||||
it('should return background pages', async({browserType}) => {
|
||||
const userDataDir = await makeUserDataDir();
|
||||
const context = await browserType.launchPersistentContext(userDataDir, extensionOptions);
|
||||
const backgroundPages = context.backgroundPages();
|
||||
|
|
@ -83,7 +77,7 @@ module.exports.describe = function({defaultBrowserOptions, browserType, WIN}) {
|
|||
});
|
||||
|
||||
describe('BrowserContext', function() {
|
||||
it('should not create pages automatically', async function() {
|
||||
it('should not create pages automatically', async ({browserType}) => {
|
||||
const browser = await browserType.launch();
|
||||
const browserSession = await browser.newBrowserCDPSession();
|
||||
const targets = [];
|
||||
|
|
@ -97,4 +91,3 @@ module.exports.describe = function({defaultBrowserOptions, browserType, WIN}) {
|
|||
expect(targets.length).toBe(0);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -14,10 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @type {ChromiumTestSuite}
|
||||
*/
|
||||
module.exports.describe = function({defaultBrowserOptions, browserType, FFOX, CHROMIUM, WEBKIT}) {
|
||||
const {FFOX, CHROMIUM, WEBKIT, defaultBrowserOptions} = require('../utils').testOptions(browserType);
|
||||
|
||||
const headfulOptions = Object.assign({}, defaultBrowserOptions, {
|
||||
headless: false
|
||||
|
|
@ -25,7 +22,7 @@ module.exports.describe = function({defaultBrowserOptions, browserType, FFOX, CH
|
|||
|
||||
describe('OOPIF', function() {
|
||||
beforeAll(async function(state) {
|
||||
state.browser = await browserType.launch(Object.assign({}, defaultBrowserOptions, {
|
||||
state.browser = await state.browserType.launch(Object.assign({}, defaultBrowserOptions, {
|
||||
args: (defaultBrowserOptions.args || []).concat(['--site-per-process']),
|
||||
}));
|
||||
});
|
||||
|
|
@ -75,7 +72,7 @@ module.exports.describe = function({defaultBrowserOptions, browserType, FFOX, CH
|
|||
await page.click('button');
|
||||
expect(await page.evaluate(() => window.BUTTON_CLICKED)).toBe(true);
|
||||
});
|
||||
it('should report google.com frame with headful', async({server}) => {
|
||||
it('should report google.com frame with headful', async({browserType, server}) => {
|
||||
// TODO: Support OOOPIF. @see https://github.com/GoogleChrome/puppeteer/issues/2548
|
||||
// https://google.com is isolated by default in Chromium embedder.
|
||||
const browser = await browserType.launch(headfulOptions);
|
||||
|
|
@ -99,7 +96,6 @@ module.exports.describe = function({defaultBrowserOptions, browserType, FFOX, CH
|
|||
await browser.close();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
async function countOOPIFs(browser) {
|
||||
const browserSession = await browser.newBrowserCDPSession();
|
||||
|
|
|
|||
|
|
@ -16,11 +16,7 @@
|
|||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
/**
|
||||
* @type {ChromiumTestSuite}
|
||||
*/
|
||||
module.exports.describe = function({headless, OUTPUT_DIR}) {
|
||||
const {FFOX, CHROMIUM, WEBKIT, headless, OUTPUT_DIR} = require('../utils').testOptions(browserType);
|
||||
|
||||
// Printing to pdf is currently only supported in headless
|
||||
describe.fail(!headless)('Page.pdf', function() {
|
||||
|
|
@ -31,4 +27,3 @@ module.exports.describe = function({headless, OUTPUT_DIR}) {
|
|||
fs.unlinkSync(outputFile);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -14,10 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @type {ChromiumTestSuite}
|
||||
*/
|
||||
module.exports.describe = function({FFOX, CHROMIUM, WEBKIT}) {
|
||||
const {FFOX, CHROMIUM, WEBKIT} = require('../utils').testOptions(browserType);
|
||||
|
||||
describe('ChromiumBrowserContext.createSession', function() {
|
||||
it('should work', async function({page, browser, server}) {
|
||||
|
|
@ -104,4 +101,3 @@ module.exports.describe = function({FFOX, CHROMIUM, WEBKIT}) {
|
|||
await session.detach();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -16,16 +16,12 @@
|
|||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
/**
|
||||
* @type {ChromiumTestSuite}
|
||||
*/
|
||||
module.exports.describe = function({defaultBrowserOptions, browserType, OUTPUT_DIR}) {
|
||||
const {FFOX, CHROMIUM, WEBKIT, OUTPUT_DIR, defaultBrowserOptions} = require('../utils').testOptions(browserType);
|
||||
|
||||
describe('Chromium.startTracing', function() {
|
||||
beforeEach(async function(state) {
|
||||
state.outputFile = path.join(OUTPUT_DIR, `trace-${state.parallelIndex}.json`);
|
||||
state.browser = await browserType.launch(defaultBrowserOptions);
|
||||
state.browser = await state.browserType.launch(defaultBrowserOptions);
|
||||
state.page = await state.browser.newPage();
|
||||
});
|
||||
afterEach(async function(state) {
|
||||
|
|
@ -79,4 +75,3 @@ module.exports.describe = function({defaultBrowserOptions, browserType, OUTPUT_D
|
|||
expect(trace.toString()).toContain('screenshot', 'Does not contain screenshot');
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -16,11 +16,7 @@
|
|||
*/
|
||||
|
||||
const utils = require('./utils');
|
||||
|
||||
/**
|
||||
* @type {PageTestSuite}
|
||||
*/
|
||||
module.exports.describe = function({playwright, FFOX, CHROMIUM, WEBKIT}) {
|
||||
const {FFOX, CHROMIUM, WEBKIT} = utils.testOptions(browserType);
|
||||
|
||||
describe('Page.click', function() {
|
||||
it('should click the button', async({page, server}) => {
|
||||
|
|
@ -613,4 +609,3 @@ const utils = require('./utils');
|
|||
expect(await page.evaluate(() => checkbox.getAttribute('aria-checked'))).toBe('true');
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -15,10 +15,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @type {PageTestSuite}
|
||||
*/
|
||||
module.exports.describe = function({browserType, defaultBrowserOptions, MAC, FFOX, CHROMIUM, WEBKIT}) {
|
||||
const {FFOX, CHROMIUM, WEBKIT, MAC, defaultBrowserOptions} = require('./utils').testOptions(browserType);
|
||||
|
||||
describe('BrowserContext.cookies', function() {
|
||||
it('should return no cookies in pristine browser context', async({context, page, server}) => {
|
||||
|
|
@ -272,7 +269,7 @@ module.exports.describe = function({browserType, defaultBrowserOptions, MAC, FFO
|
|||
await context.close();
|
||||
}
|
||||
});
|
||||
it.slow()('should isolate cookies between launches', async({server}) => {
|
||||
it.slow()('should isolate cookies between launches', async({browserType, server}) => {
|
||||
const browser1 = await browserType.launch(defaultBrowserOptions);
|
||||
const context1 = await browser1.newContext();
|
||||
await context1.addCookies([{url: server.EMPTY_PAGE, name: 'cookie-in-context-1', value: 'value', expires: Date.now() / 1000 + 10000}]);
|
||||
|
|
@ -469,4 +466,3 @@ module.exports.describe = function({browserType, defaultBrowserOptions, MAC, FFO
|
|||
await anotherContext.close();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -15,17 +15,14 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
const { makeUserDataDir, removeUserDataDir } = require('./utils');
|
||||
|
||||
/**
|
||||
* @type {PageTestSuite}
|
||||
*/
|
||||
module.exports.describe = function ({ defaultBrowserOptions, browserType, WEBKIT }) {
|
||||
const utils = require('./utils');
|
||||
const {makeUserDataDir, removeUserDataDir} = utils;
|
||||
const {FFOX, CHROMIUM, WEBKIT, defaultBrowserOptions} = utils.testOptions(browserType);
|
||||
|
||||
describe('launchPersistentContext()', function() {
|
||||
beforeEach(async state => {
|
||||
state.userDataDir = await makeUserDataDir();
|
||||
state.browserContext = await browserType.launchPersistentContext(state.userDataDir, defaultBrowserOptions);
|
||||
state.browserContext = await state.browserType.launchPersistentContext(state.userDataDir, defaultBrowserOptions);
|
||||
state.page = await state.browserContext.newPage();
|
||||
});
|
||||
afterEach(async state => {
|
||||
|
|
@ -87,4 +84,3 @@ module.exports.describe = function ({ defaultBrowserOptions, browserType, WEBKIT
|
|||
expect(await page.evaluate('document.cookie')).toBe('');
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -15,10 +15,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @type {PageTestSuite}
|
||||
*/
|
||||
module.exports.describe = function({FFOX, CHROMIUM, WEBKIT}) {
|
||||
const {FFOX, CHROMIUM, WEBKIT} = require('./utils').testOptions(browserType);
|
||||
|
||||
describe('Page.Events.Dialog', function() {
|
||||
it('should fire', async({page, server}) => {
|
||||
|
|
@ -62,4 +59,3 @@ module.exports.describe = function({FFOX, CHROMIUM, WEBKIT}) {
|
|||
expect(result).toBe(false);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -16,8 +16,7 @@
|
|||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
module.exports.describe = function({browserType, defaultBrowserOptions, CHROMIUM, WEBKIT, FFOX, WIN, MAC}) {
|
||||
const {FFOX, CHROMIUM, WEBKIT, defaultBrowserOptions} = require('./utils').testOptions(browserType);
|
||||
|
||||
describe('Download', function() {
|
||||
beforeEach(async(state) => {
|
||||
|
|
@ -97,7 +96,7 @@ module.exports.describe = function({browserType, defaultBrowserOptions, CHROMIUM
|
|||
expect(fs.existsSync(path1)).toBeFalsy();
|
||||
expect(fs.existsSync(path2)).toBeFalsy();
|
||||
});
|
||||
it('should delete downloads on browser gone', async ({ server }) => {
|
||||
it('should delete downloads on browser gone', async ({ server, browserType }) => {
|
||||
const browser = await browserType.launch(defaultBrowserOptions);
|
||||
const page = await browser.newPage({ acceptDownloads: true });
|
||||
await page.setContent(`<a download=true href="${server.PREFIX}/download">download</a>`);
|
||||
|
|
@ -119,4 +118,3 @@ module.exports.describe = function({browserType, defaultBrowserOptions, CHROMIUM
|
|||
expect(fs.existsSync(path.join(path1, '..'))).toBeFalsy();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -16,11 +16,7 @@
|
|||
*/
|
||||
|
||||
const utils = require('./utils');
|
||||
|
||||
/**
|
||||
* @type {PageTestSuite}
|
||||
*/
|
||||
module.exports.describe = function({FFOX, CHROMIUM, WEBKIT}) {
|
||||
const {FFOX, CHROMIUM, WEBKIT} = require('./utils').testOptions(browserType);
|
||||
|
||||
describe('ElementHandle.boundingBox', function() {
|
||||
it('should work', async({page, server}) => {
|
||||
|
|
@ -330,4 +326,3 @@ module.exports.describe = function({FFOX, CHROMIUM, WEBKIT}) {
|
|||
expect(await page.evaluate(() => result)).toBe('some value');
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -16,11 +16,7 @@
|
|||
*/
|
||||
|
||||
const utils = require('./utils');
|
||||
|
||||
/**
|
||||
* @type {PageTestSuite}
|
||||
*/
|
||||
module.exports.describe = function({playwright, headless, FFOX, CHROMIUM, WEBKIT, MAC, WIN}) {
|
||||
const {FFOX, CHROMIUM, WEBKIT, headless} = utils.testOptions(browserType);
|
||||
const iPhone = playwright.devices['iPhone 6'];
|
||||
const iPhoneLandscape = playwright.devices['iPhone 6 landscape'];
|
||||
|
||||
|
|
@ -461,4 +457,3 @@ module.exports.describe = function({playwright, headless, FFOX, CHROMIUM, WEBKIT
|
|||
await page2.close();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -17,11 +17,7 @@
|
|||
|
||||
const utils = require('./utils');
|
||||
const path = require('path');
|
||||
|
||||
/**
|
||||
* @type {PageTestSuite}
|
||||
*/
|
||||
module.exports.describe = function({FFOX, CHROMIUM, WEBKIT, LINUX}) {
|
||||
const {FFOX, CHROMIUM, WEBKIT} = utils.testOptions(browserType);
|
||||
|
||||
describe('Page.evaluate', function() {
|
||||
it('should work', async({page, server}) => {
|
||||
|
|
@ -454,4 +450,3 @@ module.exports.describe = function({FFOX, CHROMIUM, WEBKIT, LINUX}) {
|
|||
expect(constructorName).toBe('HTMLIFrameElement');
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -17,13 +17,9 @@
|
|||
|
||||
const path = require('path');
|
||||
const {spawn, execSync} = require('child_process');
|
||||
const {FFOX, CHROMIUM, WEBKIT, WIN, playwrightPath, defaultBrowserOptions} = require('./utils').testOptions(browserType);
|
||||
|
||||
/**
|
||||
* @type {TestSuite}
|
||||
*/
|
||||
module.exports.describe = function({browserType, playwrightPath, defaultBrowserOptions, WIN, FFOX, CHROMIUM, WEBKIT}) {
|
||||
|
||||
async function testSignal(action, exitOnClose) {
|
||||
async function testSignal(browserType, action, exitOnClose) {
|
||||
const options = Object.assign({}, defaultBrowserOptions, {
|
||||
// Disable DUMPIO to cleanly read stdout.
|
||||
dumpio: false,
|
||||
|
|
@ -66,15 +62,15 @@ module.exports.describe = function({browserType, playwrightPath, defaultBrowserO
|
|||
}
|
||||
|
||||
describe('Fixtures', function() {
|
||||
it.slow()('should dump browser process stderr', async({server}) => {
|
||||
it.slow()('should dump browser process stderr', async({browserType}) => {
|
||||
let dumpioData = '';
|
||||
const res = spawn('node', [path.join(__dirname, 'fixtures', 'dumpio.js'), playwrightPath, browserType.name()]);
|
||||
res.stdout.on('data', data => dumpioData += data.toString('utf8'));
|
||||
await new Promise(resolve => res.on('close', resolve));
|
||||
expect(dumpioData).toContain('message from dumpio');
|
||||
});
|
||||
it.slow()('should close the browser when the node process closes', async () => {
|
||||
const result = await testSignal(child => {
|
||||
it.slow()('should close the browser when the node process closes', async ({browserType}) => {
|
||||
const result = await testSignal(browserType, child => {
|
||||
if (WIN)
|
||||
execSync(`taskkill /pid ${child.pid} /T /F`);
|
||||
else
|
||||
|
|
@ -87,38 +83,38 @@ module.exports.describe = function({browserType, playwrightPath, defaultBrowserO
|
|||
|
||||
describe.skip(WIN)('signals', () => {
|
||||
// Cannot reliably send signals on Windows.
|
||||
it.slow()('should report browser close signal', async () => {
|
||||
const result = await testSignal((child, browserPid) => process.kill(browserPid), true);
|
||||
it.slow()('should report browser close signal', async ({browserType}) => {
|
||||
const result = await testSignal(browserType, (child, browserPid) => process.kill(browserPid), true);
|
||||
expect(result.exitCode).toBe(0);
|
||||
expect(result.browserExitCode).toBe('null');
|
||||
expect(result.browserSignal).toBe('SIGTERM');
|
||||
});
|
||||
it.slow()('should report browser close signal 2', async (state, test) => {
|
||||
const result = await testSignal((child, browserPid) => process.kill(browserPid, 'SIGKILL'), true);
|
||||
it.slow()('should report browser close signal 2', async ({browserType}) => {
|
||||
const result = await testSignal(browserType, (child, browserPid) => process.kill(browserPid, 'SIGKILL'), true);
|
||||
expect(result.exitCode).toBe(0);
|
||||
expect(result.browserExitCode).toBe('null');
|
||||
expect(result.browserSignal).toBe('SIGKILL');
|
||||
});
|
||||
it.slow()('should close the browser on SIGINT', async () => {
|
||||
const result = await testSignal(child => process.kill(child.pid, 'SIGINT'));
|
||||
it.slow()('should close the browser on SIGINT', async ({browserType}) => {
|
||||
const result = await testSignal(browserType, child => process.kill(child.pid, 'SIGINT'));
|
||||
expect(result.exitCode).toBe(130);
|
||||
expect(result.browserExitCode).toBe('0');
|
||||
expect(result.browserSignal).toBe('null');
|
||||
});
|
||||
it.slow()('should close the browser on SIGTERM', async () => {
|
||||
const result = await testSignal(child => process.kill(child.pid, 'SIGTERM'));
|
||||
it.slow()('should close the browser on SIGTERM', async ({browserType}) => {
|
||||
const result = await testSignal(browserType, child => process.kill(child.pid, 'SIGTERM'));
|
||||
expect(result.exitCode).toBe(0);
|
||||
expect(result.browserExitCode).toBe('0');
|
||||
expect(result.browserSignal).toBe('null');
|
||||
});
|
||||
it.slow()('should close the browser on SIGHUP', async () => {
|
||||
const result = await testSignal(child => process.kill(child.pid, 'SIGHUP'));
|
||||
it.slow()('should close the browser on SIGHUP', async ({browserType}) => {
|
||||
const result = await testSignal(browserType, child => process.kill(child.pid, 'SIGHUP'));
|
||||
expect(result.exitCode).toBe(0);
|
||||
expect(result.browserExitCode).toBe('0');
|
||||
expect(result.browserSignal).toBe('null');
|
||||
});
|
||||
it.slow()('should kill the browser on double SIGINT', async () => {
|
||||
const result = await testSignal(child => {
|
||||
it.slow()('should kill the browser on double SIGINT', async ({browserType}) => {
|
||||
const result = await testSignal(browserType, child => {
|
||||
process.kill(child.pid, 'SIGINT');
|
||||
process.kill(child.pid, 'SIGINT');
|
||||
});
|
||||
|
|
@ -126,8 +122,8 @@ module.exports.describe = function({browserType, playwrightPath, defaultBrowserO
|
|||
// TODO: ideally, we would expect the SIGKILL on the browser from
|
||||
// force kill, but that's racy with sending two signals.
|
||||
});
|
||||
it.slow()('should kill the browser on SIGINT + SIGTERM', async () => {
|
||||
const result = await testSignal(child => {
|
||||
it.slow()('should kill the browser on SIGINT + SIGTERM', async ({browserType}) => {
|
||||
const result = await testSignal(browserType, child => {
|
||||
process.kill(child.pid, 'SIGINT');
|
||||
process.kill(child.pid, 'SIGTERM');
|
||||
});
|
||||
|
|
@ -135,8 +131,8 @@ module.exports.describe = function({browserType, playwrightPath, defaultBrowserO
|
|||
// TODO: ideally, we would expect the SIGKILL on the browser from
|
||||
// force kill, but that's racy with sending two signals.
|
||||
});
|
||||
it.slow()('should kill the browser on SIGTERM + SIGINT', async () => {
|
||||
const result = await testSignal(child => {
|
||||
it.slow()('should kill the browser on SIGTERM + SIGINT', async ({browserType}) => {
|
||||
const result = await testSignal(browserType, child => {
|
||||
process.kill(child.pid, 'SIGTERM');
|
||||
process.kill(child.pid, 'SIGINT');
|
||||
});
|
||||
|
|
@ -146,4 +142,3 @@ module.exports.describe = function({browserType, playwrightPath, defaultBrowserO
|
|||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -14,10 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @type {PageTestSuite}
|
||||
*/
|
||||
module.exports.describe = function({}) {
|
||||
const {FFOX, CHROMIUM, WEBKIT} = require('./utils').testOptions(browserType);
|
||||
|
||||
describe('Page.focus', function() {
|
||||
it('should work', async function({page, server}) {
|
||||
|
|
@ -48,4 +45,3 @@ module.exports.describe = function({}) {
|
|||
expect(blurred).toBe(true);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -16,11 +16,7 @@
|
|||
*/
|
||||
|
||||
const utils = require('./utils');
|
||||
|
||||
/**
|
||||
* @type {PageTestSuite}
|
||||
*/
|
||||
module.exports.describe = function({FFOX, CHROMIUM, WEBKIT}) {
|
||||
const {FFOX, CHROMIUM, WEBKIT} = utils.testOptions(browserType);
|
||||
|
||||
describe('Frame.evaluateHandle', function() {
|
||||
it('should work', async({page, server}) => {
|
||||
|
|
@ -234,4 +230,3 @@ module.exports.describe = function({FFOX, CHROMIUM, WEBKIT}) {
|
|||
expect(frame1).not.toBe(frame2);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -15,10 +15,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @type {PageTestSuite}
|
||||
*/
|
||||
module.exports.describe = function ({ FFOX, WEBKIT }) {
|
||||
const {FFOX, CHROMIUM, WEBKIT} = require('./utils').testOptions(browserType);
|
||||
|
||||
describe('Overrides.setGeolocation', function() {
|
||||
it('should work', async({page, server, context}) => {
|
||||
|
|
@ -121,4 +118,3 @@ module.exports.describe = function ({ FFOX, WEBKIT }) {
|
|||
expect(geolocation).toEqual({ longitude: 10, latitude: 10 });
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -14,12 +14,9 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
const { makeUserDataDir, removeUserDataDir } = require('./utils');
|
||||
|
||||
/**
|
||||
* @type {TestSuite}
|
||||
*/
|
||||
module.exports.describe = function({browserType, defaultBrowserOptions, FFOX, CHROMIUM, WEBKIT, WIN}) {
|
||||
const utils = require('./utils');
|
||||
const { makeUserDataDir, removeUserDataDir } = utils;
|
||||
const {FFOX, CHROMIUM, WEBKIT, WIN, defaultBrowserOptions} = utils.testOptions(browserType);
|
||||
|
||||
const headfulOptions = Object.assign({}, defaultBrowserOptions, {
|
||||
headless: false
|
||||
|
|
@ -29,7 +26,7 @@ module.exports.describe = function({browserType, defaultBrowserOptions, FFOX, CH
|
|||
});
|
||||
|
||||
describe('Headful', function() {
|
||||
it('should have default url when launching browser', async function() {
|
||||
it('should have default url when launching browser', async ({browserType}) => {
|
||||
const userDataDir = await makeUserDataDir();
|
||||
const browserContext = await browserType.launchPersistentContext(userDataDir, headfulOptions);
|
||||
const urls = browserContext.pages().map(page => page.url());
|
||||
|
|
@ -37,7 +34,7 @@ module.exports.describe = function({browserType, defaultBrowserOptions, FFOX, CH
|
|||
await browserContext.close();
|
||||
await removeUserDataDir(userDataDir);
|
||||
});
|
||||
it.slow().fail(WIN && CHROMIUM)('headless should be able to read cookies written by headful', async({server}) => {
|
||||
it.slow().fail(WIN && CHROMIUM)('headless should be able to read cookies written by headful', async({browserType, server}) => {
|
||||
// see https://github.com/microsoft/playwright/issues/717
|
||||
const userDataDir = await makeUserDataDir();
|
||||
// Write a cookie in headful chrome
|
||||
|
|
@ -56,7 +53,7 @@ module.exports.describe = function({browserType, defaultBrowserOptions, FFOX, CH
|
|||
await removeUserDataDir(userDataDir);
|
||||
expect(cookie).toBe('foo=true');
|
||||
});
|
||||
it.slow()('should close browser with beforeunload page', async({server}) => {
|
||||
it.slow()('should close browser with beforeunload page', async({browserType, server}) => {
|
||||
const userDataDir = await makeUserDataDir();
|
||||
const browserContext = await browserType.launchPersistentContext(userDataDir, headfulOptions);
|
||||
const page = await browserContext.newPage();
|
||||
|
|
@ -68,4 +65,3 @@ module.exports.describe = function({browserType, defaultBrowserOptions, FFOX, CH
|
|||
await removeUserDataDir(userDataDir);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -15,10 +15,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @type {BrowserTestSuite}
|
||||
*/
|
||||
module.exports.describe = function({defaultBrowserOptions, playwright, FFOX, CHROMIUM, WEBKIT}) {
|
||||
const {FFOX, CHROMIUM, WEBKIT} = require('./utils').testOptions(browserType);
|
||||
|
||||
describe('ignoreHTTPSErrors', function() {
|
||||
it('should work', async({browser, httpsServer}) => {
|
||||
|
|
@ -64,4 +61,3 @@ module.exports.describe = function({defaultBrowserOptions, playwright, FFOX, CHR
|
|||
await context.close();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -20,11 +20,7 @@ const fs = require('fs');
|
|||
const formidable = require('formidable');
|
||||
|
||||
const FILE_TO_UPLOAD = path.join(__dirname, '/assets/file-to-upload.txt');
|
||||
|
||||
/**
|
||||
* @type {PageTestSuite}
|
||||
*/
|
||||
module.exports.describe = function({playwright, FFOX, CHROMIUM, WEBKIT}) {
|
||||
const {FFOX, CHROMIUM, WEBKIT} = require('./utils').testOptions(browserType);
|
||||
|
||||
describe('input', function() {
|
||||
it('should upload the file', async({page, server}) => {
|
||||
|
|
@ -243,4 +239,3 @@ module.exports.describe = function({playwright, FFOX, CHROMIUM, WEBKIT}) {
|
|||
expect(multiple).toBe(true);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -18,13 +18,8 @@
|
|||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const { helper } = require('../lib/helper');
|
||||
const utils = require('./utils');
|
||||
const vm = require('vm');
|
||||
|
||||
/**
|
||||
* @type {PageTestSuite}
|
||||
*/
|
||||
module.exports.describe = function({defaultBrowserOptions, playwright, FFOX, CHROMIUM, WEBKIT}) {
|
||||
const {FFOX, CHROMIUM, WEBKIT} = require('./utils').testOptions(browserType);
|
||||
|
||||
describe('Page.route', function() {
|
||||
it('should intercept', async({page, server}) => {
|
||||
|
|
@ -568,4 +563,3 @@ module.exports.describe = function({defaultBrowserOptions, playwright, FFOX, CHR
|
|||
expect(intercepted).toBe(true);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -15,10 +15,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @type {PageTestSuite}
|
||||
*/
|
||||
module.exports.describe = function({CHROMIUM, FFOX, WEBKIT}) {
|
||||
const {FFOX, CHROMIUM, WEBKIT} = require('./utils').testOptions(browserType);
|
||||
|
||||
describe('Page.evaluateHandle', function() {
|
||||
it('should work', async({page, server}) => {
|
||||
|
|
@ -274,4 +271,3 @@ module.exports.describe = function({CHROMIUM, FFOX, WEBKIT}) {
|
|||
expect((await page.evaluateHandle('new Proxy({}, {})')).toString()).toBe('JSHandle@proxy');
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -16,12 +16,7 @@
|
|||
*/
|
||||
|
||||
const utils = require('./utils');
|
||||
const os = require('os');
|
||||
|
||||
/**
|
||||
* @type {PageTestSuite}
|
||||
*/
|
||||
module.exports.describe = function({FFOX, CHROMIUM, WEBKIT, MAC}) {
|
||||
const {FFOX, CHROMIUM, WEBKIT, MAC} = require('./utils').testOptions(browserType);
|
||||
|
||||
describe('Keyboard', function() {
|
||||
it('should type into a textarea', async({page, server}) => {
|
||||
|
|
@ -309,4 +304,3 @@ module.exports.describe = function({FFOX, CHROMIUM, WEBKIT, MAC}) {
|
|||
expect(await page.evaluate('lastKey.key')).toBe('a');
|
||||
})
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -18,16 +18,12 @@
|
|||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const utils = require('./utils');
|
||||
const { makeUserDataDir, removeUserDataDir } = require('./utils');
|
||||
|
||||
/**
|
||||
* @type {TestSuite}
|
||||
*/
|
||||
module.exports.describe = function({defaultBrowserOptions, playwright, browserType, playwrightPath, CHROMIUM, FFOX, WEBKIT, WIN}) {
|
||||
const { makeUserDataDir, removeUserDataDir } = utils;
|
||||
const {FFOX, CHROMIUM, WEBKIT, WIN, defaultBrowserOptions, playwrightPath} = utils.testOptions(browserType);
|
||||
|
||||
describe('Playwright', function() {
|
||||
describe('browserType.launch', function() {
|
||||
it('should reject all promises when browser is closed', async() => {
|
||||
it('should reject all promises when browser is closed', async({browserType}) => {
|
||||
const browser = await browserType.launch(defaultBrowserOptions);
|
||||
const page = await (await browser.newContext()).newPage();
|
||||
let error = null;
|
||||
|
|
@ -36,19 +32,19 @@ module.exports.describe = function({defaultBrowserOptions, playwright, browserTy
|
|||
await neverResolves;
|
||||
expect(error.message).toContain('Protocol error');
|
||||
});
|
||||
it('should throw if userDataDir option is passed', async() => {
|
||||
it('should throw if userDataDir option is passed', async({browserType}) => {
|
||||
let waitError = null;
|
||||
const options = Object.assign({}, defaultBrowserOptions, {userDataDir: 'random-path'});
|
||||
await browserType.launch(options).catch(e => waitError = e);
|
||||
expect(waitError.message).toContain('launchPersistentContext');
|
||||
});
|
||||
it('should throw if page argument is passed', async() => {
|
||||
it('should throw if page argument is passed', async({browserType}) => {
|
||||
let waitError = null;
|
||||
const options = Object.assign({}, defaultBrowserOptions, { args: ['http://example.com'] });
|
||||
await browserType.launch(options).catch(e => waitError = e);
|
||||
expect(waitError.message).toContain('can not specify page');
|
||||
});
|
||||
it('should reject if executable path is invalid', async({server}) => {
|
||||
it('should reject if executable path is invalid', async({browserType}) => {
|
||||
let waitError = null;
|
||||
const options = Object.assign({}, defaultBrowserOptions, {executablePath: 'random-invalid-path'});
|
||||
await browserType.launch(options).catch(e => waitError = e);
|
||||
|
|
@ -57,7 +53,7 @@ module.exports.describe = function({defaultBrowserOptions, playwright, browserTy
|
|||
});
|
||||
|
||||
describe('browserType.launchPersistentContext', function() {
|
||||
it('should have default URL when launching browser', async function() {
|
||||
it('should have default URL when launching browser', async ({browserType}) => {
|
||||
const userDataDir = await makeUserDataDir();
|
||||
const browserContext = await browserType.launchPersistentContext(userDataDir, defaultBrowserOptions);
|
||||
const urls = browserContext.pages().map(page => page.url());
|
||||
|
|
@ -65,7 +61,7 @@ module.exports.describe = function({defaultBrowserOptions, playwright, browserTy
|
|||
await browserContext.close();
|
||||
await removeUserDataDir(userDataDir);
|
||||
});
|
||||
it('should have custom URL when launching browser', async function({server}) {
|
||||
it('should have custom URL when launching browser', async ({browserType, server}) => {
|
||||
const userDataDir = await makeUserDataDir();
|
||||
const options = Object.assign({}, defaultBrowserOptions);
|
||||
options.args = [server.EMPTY_PAGE].concat(options.args || []);
|
||||
|
|
@ -83,12 +79,12 @@ module.exports.describe = function({defaultBrowserOptions, playwright, browserTy
|
|||
});
|
||||
|
||||
describe('browserType.launchServer', function() {
|
||||
it('should return child_process instance', async () => {
|
||||
it('should return child_process instance', async ({browserType}) => {
|
||||
const browserServer = await browserType.launchServer(defaultBrowserOptions);
|
||||
expect(browserServer.process().pid).toBeGreaterThan(0);
|
||||
await browserServer.close();
|
||||
});
|
||||
it('should fire close event', async () => {
|
||||
it('should fire close event', async ({browserType}) => {
|
||||
const browserServer = await browserType.launchServer(defaultBrowserOptions);
|
||||
await Promise.all([
|
||||
new Promise(f => browserServer.on('close', f)),
|
||||
|
|
@ -98,7 +94,7 @@ module.exports.describe = function({defaultBrowserOptions, playwright, browserTy
|
|||
});
|
||||
|
||||
describe('browserType.executablePath', function() {
|
||||
it('should work', async({server}) => {
|
||||
it('should work', async({browserType}) => {
|
||||
const executablePath = browserType.executablePath();
|
||||
expect(fs.existsSync(executablePath)).toBe(true);
|
||||
expect(fs.realpathSync(executablePath)).toBe(executablePath);
|
||||
|
|
@ -106,7 +102,7 @@ module.exports.describe = function({defaultBrowserOptions, playwright, browserTy
|
|||
});
|
||||
|
||||
describe('browserType.name', function() {
|
||||
it('should work', async({server}) => {
|
||||
it('should work', async({browserType}) => {
|
||||
if (WEBKIT)
|
||||
expect(browserType.name()).toBe('webkit');
|
||||
else if (FFOX)
|
||||
|
|
@ -133,7 +129,7 @@ module.exports.describe = function({defaultBrowserOptions, playwright, browserTy
|
|||
});
|
||||
|
||||
describe('Browser.isConnected', () => {
|
||||
it('should set the browser connected state', async () => {
|
||||
it('should set the browser connected state', async ({browserType}) => {
|
||||
const browserServer = await browserType.launchServer({...defaultBrowserOptions });
|
||||
const remote = await browserType.connect({ wsEndpoint: browserServer.wsEndpoint() });
|
||||
expect(remote.isConnected()).toBe(true);
|
||||
|
|
@ -142,7 +138,7 @@ module.exports.describe = function({defaultBrowserOptions, playwright, browserTy
|
|||
await browserServer._checkLeaks();
|
||||
await browserServer.close();
|
||||
});
|
||||
it('should throw when used after isConnected returns false', async({server}) => {
|
||||
it('should throw when used after isConnected returns false', async({browserType}) => {
|
||||
const browserServer = await browserType.launchServer({...defaultBrowserOptions });
|
||||
const remote = await browserType.connect({ wsEndpoint: browserServer.wsEndpoint() });
|
||||
const page = await remote.newPage();
|
||||
|
|
@ -157,7 +153,7 @@ module.exports.describe = function({defaultBrowserOptions, playwright, browserTy
|
|||
});
|
||||
|
||||
describe('Browser.disconnect', function() {
|
||||
it('should reject navigation when browser closes', async({server}) => {
|
||||
it('should reject navigation when browser closes', async({browserType, server}) => {
|
||||
server.setRoute('/one-style.css', () => {});
|
||||
const browserServer = await browserType.launchServer({...defaultBrowserOptions });
|
||||
const remote = await browserType.connect({ wsEndpoint: browserServer.wsEndpoint() });
|
||||
|
|
@ -170,7 +166,7 @@ module.exports.describe = function({defaultBrowserOptions, playwright, browserTy
|
|||
await browserServer._checkLeaks();
|
||||
await browserServer.close();
|
||||
});
|
||||
it('should reject waitForSelector when browser closes', async({server}) => {
|
||||
it('should reject waitForSelector when browser closes', async({browserType, server}) => {
|
||||
server.setRoute('/empty.html', () => {});
|
||||
const browserServer = await browserType.launchServer({...defaultBrowserOptions });
|
||||
const remote = await browserType.connect({ wsEndpoint: browserServer.wsEndpoint() });
|
||||
|
|
@ -186,7 +182,7 @@ module.exports.describe = function({defaultBrowserOptions, playwright, browserTy
|
|||
await browserServer._checkLeaks();
|
||||
await browserServer.close();
|
||||
});
|
||||
it('should throw if used after disconnect', async({server}) => {
|
||||
it('should throw if used after disconnect', async({browserType}) => {
|
||||
const browserServer = await browserType.launchServer({...defaultBrowserOptions });
|
||||
const remote = await browserType.connect({ wsEndpoint: browserServer.wsEndpoint() });
|
||||
const page = await remote.newPage();
|
||||
|
|
@ -196,7 +192,7 @@ module.exports.describe = function({defaultBrowserOptions, playwright, browserTy
|
|||
await browserServer._checkLeaks();
|
||||
await browserServer.close();
|
||||
});
|
||||
it('should emit close events on pages and contexts', async({server}) => {
|
||||
it('should emit close events on pages and contexts', async({browserType}) => {
|
||||
const browserServer = await browserType.launchServer({...defaultBrowserOptions });
|
||||
const remote = await browserType.connect({ wsEndpoint: browserServer.wsEndpoint() });
|
||||
const context = await remote.newContext();
|
||||
|
|
@ -212,7 +208,7 @@ module.exports.describe = function({defaultBrowserOptions, playwright, browserTy
|
|||
});
|
||||
|
||||
describe('Browser.close', function() {
|
||||
it('should terminate network waiters', async({server}) => {
|
||||
it('should terminate network waiters', async({browserType, server}) => {
|
||||
const browserServer = await browserType.launchServer({...defaultBrowserOptions });
|
||||
const remote = await browserType.connect({ wsEndpoint: browserServer.wsEndpoint() });
|
||||
const newPage = await remote.newPage();
|
||||
|
|
@ -227,7 +223,7 @@ module.exports.describe = function({defaultBrowserOptions, playwright, browserTy
|
|||
expect(message).not.toContain('Timeout');
|
||||
}
|
||||
});
|
||||
it('should fire close event for all contexts', async(state, test) => {
|
||||
it('should fire close event for all contexts', async({browserType}) => {
|
||||
const browser = await browserType.launch(defaultBrowserOptions);
|
||||
const context = await browser.newContext();
|
||||
let closed = false;
|
||||
|
|
@ -238,7 +234,7 @@ module.exports.describe = function({defaultBrowserOptions, playwright, browserTy
|
|||
});
|
||||
|
||||
describe('browserType.launch |webSocket| option', function() {
|
||||
it('should support the webSocket option', async() => {
|
||||
it('should support the webSocket option', async({browserType}) => {
|
||||
const browserServer = await browserType.launchServer(defaultBrowserOptions);
|
||||
const browser = await browserType.connect({ wsEndpoint: browserServer.wsEndpoint() });
|
||||
const browserContext = await browser.newContext();
|
||||
|
|
@ -251,7 +247,7 @@ module.exports.describe = function({defaultBrowserOptions, playwright, browserTy
|
|||
await browserServer._checkLeaks();
|
||||
await browserServer.close();
|
||||
});
|
||||
it('should fire "disconnected" when closing with webSocket', async() => {
|
||||
it('should fire "disconnected" when closing with webSocket', async({browserType}) => {
|
||||
const browserServer = await browserType.launchServer(defaultBrowserOptions);
|
||||
const browser = await browserType.connect({ wsEndpoint: browserServer.wsEndpoint() });
|
||||
const disconnectedEventPromise = new Promise(resolve => browser.once('disconnected', resolve));
|
||||
|
|
@ -261,7 +257,7 @@ module.exports.describe = function({defaultBrowserOptions, playwright, browserTy
|
|||
});
|
||||
|
||||
describe('browserType.connect', function() {
|
||||
it.slow()('should be able to reconnect to a browser', async({server}) => {
|
||||
it.slow()('should be able to reconnect to a browser', async({browserType, server}) => {
|
||||
const browserServer = await browserType.launchServer(defaultBrowserOptions);
|
||||
{
|
||||
const browser = await browserType.connect({ wsEndpoint: browserServer.wsEndpoint() });
|
||||
|
|
@ -283,7 +279,7 @@ module.exports.describe = function({defaultBrowserOptions, playwright, browserTy
|
|||
});
|
||||
|
||||
describe('browserType.launchPersistentContext', function() {
|
||||
it('userDataDir option', async({server}) => {
|
||||
it('userDataDir option', async({browserType}) => {
|
||||
const userDataDir = await makeUserDataDir();
|
||||
const options = Object.assign(defaultBrowserOptions);
|
||||
const browserContext = await browserType.launchPersistentContext(userDataDir, options);
|
||||
|
|
@ -295,7 +291,7 @@ module.exports.describe = function({defaultBrowserOptions, playwright, browserTy
|
|||
// This might throw. See https://github.com/GoogleChrome/puppeteer/issues/2778
|
||||
await removeUserDataDir(userDataDir);
|
||||
});
|
||||
it.slow()('userDataDir option should restore state', async({server}) => {
|
||||
it.slow()('userDataDir option should restore state', async({browserType, server}) => {
|
||||
const userDataDir = await makeUserDataDir();
|
||||
const browserContext = await browserType.launchPersistentContext(userDataDir, defaultBrowserOptions);
|
||||
const page = await browserContext.newPage();
|
||||
|
|
@ -321,7 +317,7 @@ module.exports.describe = function({defaultBrowserOptions, playwright, browserTy
|
|||
await removeUserDataDir(userDataDir2);
|
||||
});
|
||||
// See https://github.com/microsoft/playwright/issues/717
|
||||
it.slow().fail(WIN && CHROMIUM)('userDataDir option should restore cookies', async({server}) => {
|
||||
it.slow().fail(WIN && CHROMIUM)('userDataDir option should restore cookies', async({browserType, server}) => {
|
||||
const userDataDir = await makeUserDataDir();
|
||||
const browserContext = await browserType.launchPersistentContext(userDataDir, defaultBrowserOptions);
|
||||
const page = await browserContext.newPage();
|
||||
|
|
@ -347,4 +343,3 @@ module.exports.describe = function({defaultBrowserOptions, playwright, browserTy
|
|||
await removeUserDataDir(userDataDir2);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
const {FFOX, CHROMIUM, WEBKIT, MAC} = require('./utils').testOptions(browserType);
|
||||
|
||||
function dimensions() {
|
||||
const rect = document.querySelector('textarea').getBoundingClientRect();
|
||||
return {
|
||||
|
|
@ -25,11 +27,6 @@ function dimensions() {
|
|||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @type {PageTestSuite}
|
||||
*/
|
||||
module.exports.describe = function({FFOX, CHROMIUM, WEBKIT, MAC}) {
|
||||
|
||||
describe('Mouse', function() {
|
||||
it('should click the document', async({page, server}) => {
|
||||
await page.evaluate(() => {
|
||||
|
|
@ -156,4 +153,3 @@ module.exports.describe = function({FFOX, CHROMIUM, WEBKIT, MAC}) {
|
|||
})
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -15,15 +15,10 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
const utils = require('./utils');
|
||||
|
||||
/**
|
||||
* @type {TestSuite}
|
||||
*/
|
||||
module.exports.describe = function({defaultBrowserOptions, browserType, FFOX, CHROMIUM, WEBKIT}) {
|
||||
const {FFOX, CHROMIUM, WEBKIT, defaultBrowserOptions} = require('./utils').testOptions(browserType);
|
||||
|
||||
describe('BrowserContext', function() {
|
||||
it('should work across sessions', async () => {
|
||||
it('should work across sessions', async ({browserType}) => {
|
||||
const browserServer = await browserType.launchServer(defaultBrowserOptions);
|
||||
const browser1 = await browserType.connect({ wsEndpoint: browserServer.wsEndpoint() });
|
||||
expect(browser1.contexts().length).toBe(0);
|
||||
|
|
@ -46,7 +41,7 @@ module.exports.describe = function({defaultBrowserOptions, browserType, FFOX, CH
|
|||
});
|
||||
|
||||
describe('Browser.Events.disconnected', function() {
|
||||
it.slow()('should be emitted when: browser gets closed, disconnected or underlying websocket gets closed', async () => {
|
||||
it.slow()('should be emitted when: browser gets closed, disconnected or underlying websocket gets closed', async ({browserType}) => {
|
||||
const browserServer = await browserType.launchServer(defaultBrowserOptions);
|
||||
const originalBrowser = await browserType.connect({ wsEndpoint: browserServer.wsEndpoint() });
|
||||
const wsEndpoint = browserServer.wsEndpoint();
|
||||
|
|
@ -82,7 +77,7 @@ module.exports.describe = function({defaultBrowserOptions, browserType, FFOX, CH
|
|||
});
|
||||
|
||||
describe('browserType.connect', function() {
|
||||
it('should be able to connect multiple times to the same browser', async({server}) => {
|
||||
it('should be able to connect multiple times to the same browser', async({browserType}) => {
|
||||
const browserServer = await browserType.launchServer(defaultBrowserOptions);
|
||||
const browser1 = await browserType.connect({ wsEndpoint: browserServer.wsEndpoint() });
|
||||
const browser2 = await browserType.connect({ wsEndpoint: browserServer.wsEndpoint() });
|
||||
|
|
@ -96,7 +91,7 @@ module.exports.describe = function({defaultBrowserOptions, browserType, FFOX, CH
|
|||
await browserServer._checkLeaks();
|
||||
await browserServer.close();
|
||||
});
|
||||
it('should not be able to close remote browser', async() => {
|
||||
it('should not be able to close remote browser', async({browserType}) => {
|
||||
const browserServer = await browserType.launchServer(defaultBrowserOptions);
|
||||
{
|
||||
const remote = await browserType.connect({ wsEndpoint: browserServer.wsEndpoint() });
|
||||
|
|
@ -112,4 +107,3 @@ module.exports.describe = function({defaultBrowserOptions, browserType, FFOX, CH
|
|||
await browserServer.close();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -18,11 +18,7 @@
|
|||
const utils = require('./utils');
|
||||
const path = require('path');
|
||||
const url = require('url');
|
||||
|
||||
/**
|
||||
* @type {PageTestSuite}
|
||||
*/
|
||||
module.exports.describe = function({playwright, MAC, WIN, FFOX, CHROMIUM, WEBKIT}) {
|
||||
const {FFOX, CHROMIUM, WEBKIT, MAC, WIN} = utils.testOptions(browserType);
|
||||
|
||||
describe('Page.goto', function() {
|
||||
it('should work', async({page, server}) => {
|
||||
|
|
@ -1081,5 +1077,3 @@ module.exports.describe = function({playwright, MAC, WIN, FFOX, CHROMIUM, WEBKIT
|
|||
expect(errorMessage).toContain('SSL_ERROR_UNKNOWN');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -18,11 +18,7 @@
|
|||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const utils = require('./utils');
|
||||
|
||||
/**
|
||||
* @type {PageTestSuite}
|
||||
*/
|
||||
module.exports.describe = function({MAC, WIN, FFOX, CHROMIUM, WEBKIT}) {
|
||||
const {FFOX, CHROMIUM, WEBKIT, MAC, WIN} = utils.testOptions(browserType);
|
||||
|
||||
describe('Page.Events.Request', function() {
|
||||
it('should fire for navigation requests', async({page, server}) => {
|
||||
|
|
@ -369,4 +365,3 @@ module.exports.describe = function({MAC, WIN, FFOX, CHROMIUM, WEBKIT}) {
|
|||
expect(error.message).toBe('Expected value of header "foo" to be String, but "number" is found.');
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -17,11 +17,7 @@
|
|||
|
||||
const path = require('path');
|
||||
const vm = require('vm');
|
||||
|
||||
/**
|
||||
* @type {PageTestSuite}
|
||||
*/
|
||||
module.exports.describe = function({playwright, FFOX, CHROMIUM, WEBKIT}) {
|
||||
const {FFOX, CHROMIUM, WEBKIT} = require('./utils').testOptions(browserType);
|
||||
|
||||
describe('Page.close', function() {
|
||||
it('should reject all promises when page is closed', async({context}) => {
|
||||
|
|
@ -1127,4 +1123,3 @@ module.exports.describe = function({playwright, FFOX, CHROMIUM, WEBKIT}) {
|
|||
expect(await frame.evaluate(() => document.querySelector('textarea').value)).toBe('a');
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -15,10 +15,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @type {PageTestSuite}
|
||||
*/
|
||||
module.exports.describe = function({WEBKIT, FFOX}) {
|
||||
const {FFOX, CHROMIUM, WEBKIT} = require('./utils').testOptions(browserType);
|
||||
|
||||
// Permissions API is not implemented in WebKit (see https://developer.mozilla.org/en-US/docs/Web/API/Permissions_API)
|
||||
describe.skip(WEBKIT)('Permissions', function() {
|
||||
|
|
@ -123,4 +120,3 @@ module.exports.describe = function({WEBKIT, FFOX}) {
|
|||
await otherContext.close();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -80,9 +80,11 @@ module.exports.addPlaywrightTests = ({testRunner, products}) => {
|
|||
const playwrightEnvironment = new Environment('Playwright');
|
||||
playwrightEnvironment.beforeAll(async state => {
|
||||
state.playwright = playwright;
|
||||
global.playwright = playwright;
|
||||
});
|
||||
playwrightEnvironment.afterAll(async state => {
|
||||
delete state.playwright;
|
||||
delete global.playwright;
|
||||
});
|
||||
|
||||
for (const product of products) {
|
||||
|
|
@ -143,21 +145,6 @@ module.exports.addPlaywrightTests = ({testRunner, products}) => {
|
|||
state.page = null;
|
||||
});
|
||||
|
||||
function loadTests(modulePath) {
|
||||
const testOptions = {
|
||||
...require('./utils').testOptions(global.browserType),
|
||||
playwright: global.playwright,
|
||||
browserType: global.browserType,
|
||||
};
|
||||
const module = require(modulePath);
|
||||
if (typeof module.describe === 'function')
|
||||
describe('', module.describe, testOptions);
|
||||
if (typeof module.fdescribe === 'function')
|
||||
fdescribe('', module.fdescribe, testOptions);
|
||||
if (typeof module.xdescribe === 'function')
|
||||
xdescribe('', module.xdescribe, testOptions);
|
||||
}
|
||||
|
||||
testRunner.collector().useEnvironment(serverEnvironment); // Custom global environment.
|
||||
testRunner.collector().useEnvironment(playwrightEnvironment);
|
||||
|
||||
|
|
@ -177,71 +164,66 @@ module.exports.addPlaywrightTests = ({testRunner, products}) => {
|
|||
|
||||
// Page-level tests that are given a browser, a context and a page.
|
||||
// Each test is launched in a new browser context.
|
||||
describe('[Accessibility]', () => loadTests('./accessibility.spec.js'));
|
||||
describe('[Driver]', () => {
|
||||
loadTests('./autowaiting.spec.js');
|
||||
loadTests('./click.spec.js');
|
||||
loadTests('./cookies.spec.js');
|
||||
loadTests('./dialog.spec.js');
|
||||
loadTests('./download.spec.js');
|
||||
loadTests('./elementhandle.spec.js');
|
||||
loadTests('./emulation.spec.js');
|
||||
loadTests('./evaluation.spec.js');
|
||||
loadTests('./frame.spec.js');
|
||||
loadTests('./focus.spec.js');
|
||||
loadTests('./input.spec.js');
|
||||
loadTests('./jshandle.spec.js');
|
||||
loadTests('./keyboard.spec.js');
|
||||
loadTests('./mouse.spec.js');
|
||||
loadTests('./navigation.spec.js');
|
||||
loadTests('./network.spec.js');
|
||||
loadTests('./page.spec.js');
|
||||
loadTests('./queryselector.spec.js');
|
||||
loadTests('./screenshot.spec.js');
|
||||
loadTests('./waittask.spec.js');
|
||||
loadTests('./interception.spec.js');
|
||||
loadTests('./geolocation.spec.js');
|
||||
loadTests('./workers.spec.js');
|
||||
loadTests('./capabilities.spec.js');
|
||||
});
|
||||
describe('[Permissions]', () => {
|
||||
loadTests('./permissions.spec.js');
|
||||
});
|
||||
require('./accessibility.spec.js');
|
||||
require('./autowaiting.spec.js');
|
||||
require('./click.spec.js');
|
||||
require('./cookies.spec.js');
|
||||
require('./dialog.spec.js');
|
||||
require('./download.spec.js');
|
||||
require('./elementhandle.spec.js');
|
||||
require('./emulation.spec.js');
|
||||
require('./evaluation.spec.js');
|
||||
require('./frame.spec.js');
|
||||
require('./focus.spec.js');
|
||||
require('./input.spec.js');
|
||||
require('./jshandle.spec.js');
|
||||
require('./keyboard.spec.js');
|
||||
require('./mouse.spec.js');
|
||||
require('./navigation.spec.js');
|
||||
require('./network.spec.js');
|
||||
require('./page.spec.js');
|
||||
require('./queryselector.spec.js');
|
||||
require('./screenshot.spec.js');
|
||||
require('./waittask.spec.js');
|
||||
require('./interception.spec.js');
|
||||
require('./geolocation.spec.js');
|
||||
require('./workers.spec.js');
|
||||
require('./capabilities.spec.js');
|
||||
require('./permissions.spec.js');
|
||||
|
||||
describe.skip(product !== 'Chromium')('[Chromium]', () => {
|
||||
loadTests('./chromium/chromium.spec.js');
|
||||
loadTests('./chromium/coverage.spec.js');
|
||||
loadTests('./chromium/pdf.spec.js');
|
||||
loadTests('./chromium/session.spec.js');
|
||||
require('./chromium/chromium.spec.js');
|
||||
require('./chromium/coverage.spec.js');
|
||||
require('./chromium/pdf.spec.js');
|
||||
require('./chromium/session.spec.js');
|
||||
});
|
||||
});
|
||||
|
||||
// Browser-level tests that are given a browser.
|
||||
describe('[Driver]', () => {
|
||||
loadTests('./browser.spec.js');
|
||||
loadTests('./browsercontext.spec.js');
|
||||
loadTests('./ignorehttpserrors.spec.js');
|
||||
loadTests('./popup.spec.js');
|
||||
require('./browser.spec.js');
|
||||
require('./browsercontext.spec.js');
|
||||
require('./ignorehttpserrors.spec.js');
|
||||
require('./popup.spec.js');
|
||||
});
|
||||
});
|
||||
|
||||
// Top-level tests that launch Browser themselves.
|
||||
describe('[Driver]', () => {
|
||||
loadTests('./defaultbrowsercontext.spec.js');
|
||||
loadTests('./fixtures.spec.js');
|
||||
loadTests('./launcher.spec.js');
|
||||
loadTests('./headful.spec.js');
|
||||
loadTests('./multiclient.spec.js');
|
||||
require('./defaultbrowsercontext.spec.js');
|
||||
require('./fixtures.spec.js');
|
||||
require('./launcher.spec.js');
|
||||
require('./headful.spec.js');
|
||||
require('./multiclient.spec.js');
|
||||
});
|
||||
|
||||
describe.skip(product !== 'Chromium')('[Chromium]', () => {
|
||||
loadTests('./chromium/launcher.spec.js');
|
||||
loadTests('./chromium/oopif.spec.js');
|
||||
loadTests('./chromium/tracing.spec.js');
|
||||
require('./chromium/launcher.spec.js');
|
||||
require('./chromium/oopif.spec.js');
|
||||
require('./chromium/tracing.spec.js');
|
||||
});
|
||||
|
||||
if (process.env.COVERAGE)
|
||||
loadTests('./apicoverage.spec.js');
|
||||
require('./apicoverage.spec.js');
|
||||
|
||||
delete global.browserType;
|
||||
delete global.playwright;
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
module.exports.describe = function({playwright, CHROMIUM, WEBKIT, FFOX}) {
|
||||
const {FFOX, CHROMIUM, WEBKIT} = require('./utils').testOptions(browserType);
|
||||
|
||||
describe('Link navigation', function() {
|
||||
it('should inherit user agent from browser context', async function({browser, server}) {
|
||||
|
|
@ -333,5 +333,3 @@ module.exports.describe = function({playwright, CHROMIUM, WEBKIT, FFOX}) {
|
|||
expect(badSecondPopup).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
};
|
||||
|
|
|
|||
|
|
@ -17,11 +17,7 @@
|
|||
|
||||
const path = require('path');
|
||||
const zsSelectorEngineSource = require('../lib/generated/zsSelectorEngineSource');
|
||||
|
||||
/**
|
||||
* @type {PageTestSuite}
|
||||
*/
|
||||
module.exports.describe = function({playwright, FFOX, CHROMIUM, WEBKIT}) {
|
||||
const {FFOX, CHROMIUM, WEBKIT} = require('./utils').testOptions(browserType);
|
||||
|
||||
describe('Page.$eval', function() {
|
||||
it('should work with css selector', async({page, server}) => {
|
||||
|
|
@ -650,4 +646,3 @@ module.exports.describe = function({playwright, FFOX, CHROMIUM, WEBKIT}) {
|
|||
expect(error.message).toBe('"css" is a predefined selector engine');
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -15,10 +15,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @type {PageTestSuite}
|
||||
*/
|
||||
module.exports.describe = function({FFOX, CHROMIUM, WEBKIT, LINUX }) {
|
||||
const {FFOX, CHROMIUM, WEBKIT} = require('./utils').testOptions(browserType);
|
||||
|
||||
describe('Page.screenshot', function() {
|
||||
it('should work', async({page, server}) => {
|
||||
|
|
@ -480,4 +477,3 @@ module.exports.describe = function({FFOX, CHROMIUM, WEBKIT, LINUX }) {
|
|||
await context.close();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -16,11 +16,7 @@
|
|||
*/
|
||||
|
||||
const utils = require('./utils');
|
||||
|
||||
/**
|
||||
* @type {PageTestSuite}
|
||||
*/
|
||||
module.exports.describe = function({playwright, FFOX, CHROMIUM, WEBKIT}) {
|
||||
const {FFOX, CHROMIUM, WEBKIT} = utils.testOptions(browserType);
|
||||
|
||||
describe('Page.waitFor', function() {
|
||||
it('should wait for selector', async({page, server}) => {
|
||||
|
|
@ -463,5 +459,3 @@ module.exports.describe = function({playwright, FFOX, CHROMIUM, WEBKIT}) {
|
|||
expect(await page.evaluate(x => x.textContent, await waitForXPath)).toBe('some text');
|
||||
});
|
||||
});
|
||||
|
||||
};
|
||||
|
|
|
|||
|
|
@ -15,10 +15,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @type {PageTestSuite}
|
||||
*/
|
||||
module.exports.describe = function({FFOX, CHROMIUM, WEBKIT, LINUX}) {
|
||||
const {FFOX, CHROMIUM, WEBKIT} = require('./utils').testOptions(browserType);
|
||||
|
||||
describe('Workers', function() {
|
||||
it('Page.workers', async function({page, server}) {
|
||||
|
|
@ -137,4 +134,3 @@ module.exports.describe = function({FFOX, CHROMIUM, WEBKIT, LINUX}) {
|
|||
await context.close();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue