mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
test(firefox): support Puppeteer-Firefox specific env variables (#3907)
This patch: - adds support to `FFOX` env variable for Puppeteer testsuite - install Firefox preferences when running tests with custom firefox executable References #3889
This commit is contained in:
parent
e1000009a5
commit
dd8bd6dcb1
@ -22,7 +22,7 @@ const {Matchers} = require('../utils/testrunner/');
|
|||||||
const YELLOW_COLOR = '\x1b[33m';
|
const YELLOW_COLOR = '\x1b[33m';
|
||||||
const RESET_COLOR = '\x1b[0m';
|
const RESET_COLOR = '\x1b[0m';
|
||||||
|
|
||||||
module.exports.addTests = ({testRunner, product, puppeteer, Errors, DeviceDescriptors, defaultBrowserOptions}) => {
|
module.exports.addTests = ({testRunner, product, puppeteer, Errors, DeviceDescriptors, slowMo, headless}) => {
|
||||||
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;
|
||||||
@ -30,6 +30,14 @@ module.exports.addTests = ({testRunner, product, puppeteer, Errors, DeviceDescri
|
|||||||
const CHROME = product === 'Chromium';
|
const CHROME = product === 'Chromium';
|
||||||
const FFOX = product === 'Firefox';
|
const FFOX = product === 'Firefox';
|
||||||
|
|
||||||
|
const defaultBrowserOptions = {
|
||||||
|
handleSIGINT: false,
|
||||||
|
executablePath: CHROME ? process.env.CHROME : process.env.FFOX,
|
||||||
|
slowMo,
|
||||||
|
headless,
|
||||||
|
dumpio: (process.env.DUMPIO || 'false').trim().toLowerCase() === 'true',
|
||||||
|
};
|
||||||
|
|
||||||
if (defaultBrowserOptions.executablePath) {
|
if (defaultBrowserOptions.executablePath) {
|
||||||
console.warn(`${YELLOW_COLOR}WARN: running ${product} tests with ${defaultBrowserOptions.executablePath}${RESET_COLOR}`);
|
console.warn(`${YELLOW_COLOR}WARN: running ${product} tests with ${defaultBrowserOptions.executablePath}${RESET_COLOR}`);
|
||||||
} else {
|
} else {
|
||||||
@ -59,6 +67,11 @@ module.exports.addTests = ({testRunner, product, puppeteer, Errors, DeviceDescri
|
|||||||
headless: !!defaultBrowserOptions.headless,
|
headless: !!defaultBrowserOptions.headless,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
beforeAll(async() => {
|
||||||
|
if (FFOX && defaultBrowserOptions.executablePath)
|
||||||
|
await require('../experimental/puppeteer-firefox/misc/install-preferences')(defaultBrowserOptions.executablePath);
|
||||||
|
});
|
||||||
|
|
||||||
describe('Browser', function() {
|
describe('Browser', function() {
|
||||||
beforeAll(async state => {
|
beforeAll(async state => {
|
||||||
state.browser = await puppeteer.launch(defaultBrowserOptions);
|
state.browser = await puppeteer.launch(defaultBrowserOptions);
|
||||||
|
13
test/test.js
13
test/test.js
@ -20,13 +20,6 @@ const utils = require('./utils');
|
|||||||
|
|
||||||
const headless = (process.env.HEADLESS || 'true').trim().toLowerCase() === 'true';
|
const headless = (process.env.HEADLESS || 'true').trim().toLowerCase() === 'true';
|
||||||
const slowMo = parseInt((process.env.SLOW_MO || '0').trim(), 10);
|
const slowMo = parseInt((process.env.SLOW_MO || '0').trim(), 10);
|
||||||
const defaultBrowserOptions = {
|
|
||||||
handleSIGINT: false,
|
|
||||||
executablePath: process.env.CHROME,
|
|
||||||
slowMo,
|
|
||||||
headless,
|
|
||||||
dumpio: (process.env.DUMPIO || 'false').trim().toLowerCase() === 'true',
|
|
||||||
};
|
|
||||||
|
|
||||||
let parallel = 1;
|
let parallel = 1;
|
||||||
if (process.env.PPTR_PARALLEL_TESTS)
|
if (process.env.PPTR_PARALLEL_TESTS)
|
||||||
@ -93,8 +86,9 @@ if (process.env.BROWSER !== 'firefox') {
|
|||||||
puppeteer: utils.requireRoot('index'),
|
puppeteer: utils.requireRoot('index'),
|
||||||
Errors: utils.requireRoot('Errors'),
|
Errors: utils.requireRoot('Errors'),
|
||||||
DeviceDescriptors: utils.requireRoot('DeviceDescriptors'),
|
DeviceDescriptors: utils.requireRoot('DeviceDescriptors'),
|
||||||
defaultBrowserOptions,
|
|
||||||
testRunner,
|
testRunner,
|
||||||
|
slowMo,
|
||||||
|
headless,
|
||||||
});
|
});
|
||||||
if (process.env.COVERAGE)
|
if (process.env.COVERAGE)
|
||||||
utils.recordAPICoverage(testRunner, require('../lib/api'), CHROMIUM_NO_COVERAGE);
|
utils.recordAPICoverage(testRunner, require('../lib/api'), CHROMIUM_NO_COVERAGE);
|
||||||
@ -106,8 +100,9 @@ if (process.env.BROWSER !== 'firefox') {
|
|||||||
puppeteer: require('../experimental/puppeteer-firefox'),
|
puppeteer: require('../experimental/puppeteer-firefox'),
|
||||||
Errors: require('../experimental/puppeteer-firefox/Errors'),
|
Errors: require('../experimental/puppeteer-firefox/Errors'),
|
||||||
DeviceDescriptors: utils.requireRoot('DeviceDescriptors'),
|
DeviceDescriptors: utils.requireRoot('DeviceDescriptors'),
|
||||||
defaultBrowserOptions,
|
|
||||||
testRunner,
|
testRunner,
|
||||||
|
slowMo,
|
||||||
|
headless,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user