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:
Andrey Lushnikov
2019-02-05 13:17:02 -08:00
committed by GitHub
parent e1000009a5
commit dd8bd6dcb1
2 changed files with 18 additions and 10 deletions

View File

@@ -22,7 +22,7 @@ const {Matchers} = require('../utils/testrunner/');
const YELLOW_COLOR = '\x1b[33m';
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 {it, fit, xit} = testRunner;
const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;
@@ -30,6 +30,14 @@ module.exports.addTests = ({testRunner, product, puppeteer, Errors, DeviceDescri
const CHROME = product === 'Chromium';
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) {
console.warn(`${YELLOW_COLOR}WARN: running ${product} tests with ${defaultBrowserOptions.executablePath}${RESET_COLOR}`);
} else {
@@ -59,6 +67,11 @@ module.exports.addTests = ({testRunner, product, puppeteer, Errors, DeviceDescri
headless: !!defaultBrowserOptions.headless,
};
beforeAll(async() => {
if (FFOX && defaultBrowserOptions.executablePath)
await require('../experimental/puppeteer-firefox/misc/install-preferences')(defaultBrowserOptions.executablePath);
});
describe('Browser', function() {
beforeAll(async state => {
state.browser = await puppeteer.launch(defaultBrowserOptions);