mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
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:
committed by
Mathias Bynens
parent
5c91dfbf3f
commit
3d56a9e76f
@@ -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 = () => {
|
||||
|
||||
Reference in New Issue
Block a user