chore: add test configuration options for running tests against multiple products (#5964)

* chore: remove "Extracting..." log message

Fixes #5741.

* test: support extra Launcher options and skips

The extra Launcher options and skipping conditions enable
unit tests to be run more easily by third-parties, e.g.
browser vendors that are interested in Puppeteer support.

Extra Launcher options were previously removed as part of
switching away from the custom test harness.

* test: enable more tests for Firefox
This commit is contained in:
Maja Frydrychowicz
2020-06-12 09:55:51 -04:00
committed by Mathias Bynens
parent 5c91dfbf3f
commit 3d56a9e76f
20 changed files with 337 additions and 370 deletions

View File

@@ -53,17 +53,32 @@ exports.getTestState = () => state;
const product =
process.env.PRODUCT || process.env.PUPPETEER_PRODUCT || 'Chromium';
const alternativeInstall = process.env.PUPPETEER_ALT_INSTALL || false;
const isHeadless =
(process.env.HEADLESS || 'true').trim().toLowerCase() === 'true';
const isFirefox = product === 'firefox';
const isChrome = product === 'Chromium';
const defaultBrowserOptions = {
handleSIGINT: false,
executablePath: process.env.BINARY,
slowMo: false,
headless: isHeadless,
dumpio: !!process.env.DUMPIO,
};
let extraLaunchOptions = {};
try {
extraLaunchOptions = JSON.parse(process.env.EXTRA_LAUNCH_OPTIONS || '{}');
} catch (error) {
console.warn(
`Error parsing EXTRA_LAUNCH_OPTIONS: ${error.message}. Skipping.`
);
}
const defaultBrowserOptions = Object.assign(
{
handleSIGINT: false,
executablePath: process.env.BINARY,
slowMo: false,
headless: isHeadless,
dumpio: !!process.env.DUMPIO,
},
extraLaunchOptions
);
(async () => {
if (defaultBrowserOptions.executablePath) {
@@ -97,6 +112,16 @@ global.itFailsFirefox = (...args) => {
else return it(...args);
};
global.itChromeOnly = (...args) => {
if (isChrome) return it(...args);
else return xit(...args);
};
global.itOnlyRegularInstall = (...args) => {
if (alternativeInstall || process.env.BINARY) return xit(...args);
else return it(...args);
};
global.itFailsWindowsUntilDate = (date, ...args) => {
if (os.platform() === 'win32' && Date.now() < date) {
// we are within the deferred time so skip the test
@@ -120,7 +145,10 @@ if (process.env.COVERAGE) trackCoverage();
console.log(
`Running unit tests with:
-> product: ${product}
-> binary: ${path.relative(process.cwd(), puppeteer.executablePath())}`
-> binary: ${
defaultBrowserOptions.executablePath ||
path.relative(process.cwd(), puppeteer.executablePath())
}`
);
exports.setupTestBrowserHooks = () => {