mirror of
https://github.com/microsoft/playwright.git
synced 2024-12-14 21:53:35 +03:00
test: rearrange remaining launcher tests
This commit is contained in:
parent
0e03c44c01
commit
0353dbb3be
@ -63,6 +63,19 @@ module.exports.addTests = function({testRunner, expect, defaultBrowserOptions, p
|
|||||||
expect(playwright.defaultArgs({headless: false})).not.toContain('--headless');
|
expect(playwright.defaultArgs({headless: false})).not.toContain('--headless');
|
||||||
expect(playwright.defaultArgs({userDataDir: 'foo'})).toContain('--user-data-dir=foo');
|
expect(playwright.defaultArgs({userDataDir: 'foo'})).toContain('--user-data-dir=foo');
|
||||||
});
|
});
|
||||||
|
it('should filter out ignored default arguments', async() => {
|
||||||
|
// Make sure we launch with `--enable-automation` by default.
|
||||||
|
const defaultArgs = playwright.defaultArgs(defaultBrowserOptions);
|
||||||
|
const browser = await playwright.launch(Object.assign({}, defaultBrowserOptions, {
|
||||||
|
// Ignore first and third default argument.
|
||||||
|
ignoreDefaultArgs: [ defaultArgs[0], defaultArgs[2] ],
|
||||||
|
}));
|
||||||
|
const spawnargs = browser.process().spawnargs;
|
||||||
|
expect(spawnargs.indexOf(defaultArgs[0])).toBe(-1);
|
||||||
|
expect(spawnargs.indexOf(defaultArgs[1])).not.toBe(-1);
|
||||||
|
expect(spawnargs.indexOf(defaultArgs[2])).toBe(-1);
|
||||||
|
await browser.close();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
describe('Playwright.launch |browserURL| option', function() {
|
describe('Playwright.launch |browserURL| option', function() {
|
||||||
it('should be able to connect using browserUrl, with and without trailing slash', async({server}) => {
|
it('should be able to connect using browserUrl, with and without trailing slash', async({server}) => {
|
||||||
|
@ -62,6 +62,19 @@ module.exports.addTests = function ({ testRunner, expect, defaultBrowserOptions,
|
|||||||
expect(playwright.defaultArgs({browser: 'firefox', userDataDir: 'foo'})).toContain('-profile');
|
expect(playwright.defaultArgs({browser: 'firefox', userDataDir: 'foo'})).toContain('-profile');
|
||||||
expect(playwright.defaultArgs({browser: 'firefox', userDataDir: 'foo'})).toContain('foo');
|
expect(playwright.defaultArgs({browser: 'firefox', userDataDir: 'foo'})).toContain('foo');
|
||||||
});
|
});
|
||||||
|
it('should filter out ignored default arguments', async() => {
|
||||||
|
// Make sure we launch with `--enable-automation` by default.
|
||||||
|
const defaultArgs = playwright.defaultArgs(defaultBrowserOptions);
|
||||||
|
const browser = await playwright.launch(Object.assign({}, defaultBrowserOptions, {
|
||||||
|
// Ignore first and third default argument.
|
||||||
|
ignoreDefaultArgs: [ defaultArgs[0], defaultArgs[2] ],
|
||||||
|
}));
|
||||||
|
const spawnargs = browser.process().spawnargs;
|
||||||
|
expect(spawnargs.indexOf(defaultArgs[0])).toBe(-1);
|
||||||
|
expect(spawnargs.indexOf(defaultArgs[1])).not.toBe(-1);
|
||||||
|
expect(spawnargs.indexOf(defaultArgs[2])).toBe(-1);
|
||||||
|
await browser.close();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -23,7 +23,7 @@ const mkdtempAsync = helper.promisify(fs.mkdtemp);
|
|||||||
const TMP_FOLDER = path.join(os.tmpdir(), 'pptr_tmp_folder-');
|
const TMP_FOLDER = path.join(os.tmpdir(), 'pptr_tmp_folder-');
|
||||||
const utils = require('./utils');
|
const utils = require('./utils');
|
||||||
|
|
||||||
module.exports.addTests = function({testRunner, expect, defaultBrowserOptions, playwright, WEBKIT}) {
|
module.exports.addTests = function({testRunner, expect, defaultBrowserOptions, playwright}) {
|
||||||
const {describe, xdescribe, fdescribe} = testRunner;
|
const {describe, xdescribe, fdescribe} = testRunner;
|
||||||
const {it, fit, xit} = testRunner;
|
const {it, fit, xit} = testRunner;
|
||||||
const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;
|
const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;
|
||||||
@ -45,42 +45,7 @@ module.exports.addTests = function({testRunner, expect, defaultBrowserOptions, p
|
|||||||
await playwright.launch(options).catch(e => waitError = e);
|
await playwright.launch(options).catch(e => waitError = e);
|
||||||
expect(waitError.message).toContain('Failed to launch');
|
expect(waitError.message).toContain('Failed to launch');
|
||||||
});
|
});
|
||||||
it.skip(WEBKIT)('userDataDir option', async({server}) => {
|
it('should set the default viewport', async() => {
|
||||||
const userDataDir = await mkdtempAsync(TMP_FOLDER);
|
|
||||||
const options = Object.assign({userDataDir}, defaultBrowserOptions);
|
|
||||||
const browser = await playwright.launch(options);
|
|
||||||
// Open a page to make sure its functional.
|
|
||||||
await browser.newPage();
|
|
||||||
expect(fs.readdirSync(userDataDir).length).toBeGreaterThan(0);
|
|
||||||
await browser.close();
|
|
||||||
expect(fs.readdirSync(userDataDir).length).toBeGreaterThan(0);
|
|
||||||
// This might throw. See https://github.com/GoogleChrome/puppeteer/issues/2778
|
|
||||||
await rmAsync(userDataDir).catch(e => {});
|
|
||||||
});
|
|
||||||
it.skip(WEBKIT)('userDataDir argument', async({server}) => {
|
|
||||||
const userDataDir = await mkdtempAsync(TMP_FOLDER);
|
|
||||||
const options = Object.assign({}, defaultBrowserOptions);
|
|
||||||
options.ignoreDefaultArgs = true;
|
|
||||||
const browser = await playwright.launch(options);
|
|
||||||
const page = await browser.newPage();
|
|
||||||
expect(await page.evaluate('11 * 11')).toBe(121);
|
|
||||||
await page.close();
|
|
||||||
await browser.close();
|
|
||||||
});
|
|
||||||
it.skip(WEBKIT)('should filter out ignored default arguments', async() => {
|
|
||||||
// Make sure we launch with `--enable-automation` by default.
|
|
||||||
const defaultArgs = playwright.defaultArgs(defaultBrowserOptions);
|
|
||||||
const browser = await playwright.launch(Object.assign({}, defaultBrowserOptions, {
|
|
||||||
// Ignore first and third default argument.
|
|
||||||
ignoreDefaultArgs: [ defaultArgs[0], defaultArgs[2] ],
|
|
||||||
}));
|
|
||||||
const spawnargs = browser.process().spawnargs;
|
|
||||||
expect(spawnargs.indexOf(defaultArgs[0])).toBe(-1);
|
|
||||||
expect(spawnargs.indexOf(defaultArgs[1])).not.toBe(-1);
|
|
||||||
expect(spawnargs.indexOf(defaultArgs[2])).toBe(-1);
|
|
||||||
await browser.close();
|
|
||||||
});
|
|
||||||
it.skip(WEBKIT)('should set the default viewport', async() => {
|
|
||||||
const options = Object.assign({}, defaultBrowserOptions, {
|
const options = Object.assign({}, defaultBrowserOptions, {
|
||||||
defaultViewport: {
|
defaultViewport: {
|
||||||
width: 456,
|
width: 456,
|
||||||
|
Loading…
Reference in New Issue
Block a user