2019-11-18 18:18:28 -08:00
|
|
|
/**
|
|
|
|
* Copyright 2017 Google Inc. All rights reserved.
|
2019-12-10 13:21:51 -08:00
|
|
|
* Modifications copyright (c) Microsoft Corporation.
|
2019-11-18 18:18:28 -08:00
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
2020-04-01 18:02:43 -07:00
|
|
|
|
2019-11-18 18:18:28 -08:00
|
|
|
const {TestRunner, Reporter} = require('../utils/testrunner/');
|
|
|
|
const utils = require('./utils');
|
2020-04-01 18:02:43 -07:00
|
|
|
const os = require('os');
|
2019-11-18 18:18:28 -08:00
|
|
|
|
|
|
|
let parallel = 1;
|
2020-01-24 16:15:41 -08:00
|
|
|
if (process.env.PW_PARALLEL_TESTS)
|
|
|
|
parallel = parseInt(process.env.PW_PARALLEL_TESTS.trim(), 10);
|
2019-11-18 18:18:28 -08:00
|
|
|
const parallelArgIndex = process.argv.indexOf('-j');
|
|
|
|
if (parallelArgIndex !== -1)
|
|
|
|
parallel = parseInt(process.argv[parallelArgIndex + 1], 10);
|
|
|
|
require('events').defaultMaxListeners *= parallel;
|
|
|
|
|
2020-01-13 17:16:05 -08:00
|
|
|
let timeout = process.env.CI ? 30 * 1000 : 10 * 1000;
|
2019-11-18 18:18:28 -08:00
|
|
|
if (!isNaN(process.env.TIMEOUT))
|
2020-02-10 10:08:51 -08:00
|
|
|
timeout = parseInt(process.env.TIMEOUT * 1000, 10);
|
2020-03-28 08:49:00 -07:00
|
|
|
const MAJOR_NODEJS_VERSION = parseInt(process.version.substring(1).split('.')[0], 10);
|
2020-04-01 18:02:43 -07:00
|
|
|
if (MAJOR_NODEJS_VERSION >= 8 && require('inspector').url()) {
|
2020-03-28 08:49:00 -07:00
|
|
|
console.log('Detected inspector - disabling timeout to be debugger-friendly');
|
|
|
|
timeout = 0;
|
|
|
|
}
|
|
|
|
|
2019-11-18 18:18:28 -08:00
|
|
|
const testRunner = new TestRunner({
|
|
|
|
timeout,
|
|
|
|
parallel,
|
|
|
|
breakOnFailure: process.argv.indexOf('--break-on-failure') !== -1,
|
2020-03-28 08:49:00 -07:00
|
|
|
installCommonHelpers: false
|
2019-11-18 18:18:28 -08:00
|
|
|
});
|
2020-04-01 18:02:43 -07:00
|
|
|
utils.setupTestRunner(testRunner);
|
2019-11-18 18:18:28 -08:00
|
|
|
|
|
|
|
console.log('Testing on Node', process.version);
|
|
|
|
|
2020-04-01 18:02:43 -07:00
|
|
|
const names = ['Chromium', 'Firefox', 'WebKit'].filter(name => {
|
|
|
|
return process.env.BROWSER === name.toLowerCase() || process.env.BROWSER === 'all';
|
2019-11-18 18:18:28 -08:00
|
|
|
});
|
2020-04-01 18:02:43 -07:00
|
|
|
const products = names.map(name => {
|
|
|
|
const executablePath = {
|
|
|
|
'Chromium': process.env.CRPATH,
|
|
|
|
'Firefox': process.env.FFPATH,
|
|
|
|
'WebKit': process.env.WKPATH,
|
|
|
|
}[name];
|
|
|
|
return { product: name, executablePath };
|
2019-11-18 18:18:28 -08:00
|
|
|
});
|
|
|
|
|
2020-04-01 18:02:43 -07:00
|
|
|
function valueFromEnv(name, defaultValue) {
|
|
|
|
if (!(name in process.env))
|
|
|
|
return defaultValue;
|
|
|
|
return JSON.parse(process.env[name]);
|
2020-03-07 17:09:38 -08:00
|
|
|
}
|
2020-01-16 17:46:50 -08:00
|
|
|
|
2020-04-01 18:02:43 -07:00
|
|
|
require('./playwright.spec.js').addPlaywrightTests({
|
|
|
|
playwrightPath: utils.projectRoot(),
|
|
|
|
products,
|
|
|
|
platform: os.platform(),
|
|
|
|
testRunner,
|
|
|
|
headless: !!valueFromEnv('HEADLESS', true),
|
|
|
|
slowMo: valueFromEnv('SLOW_MO', 0),
|
|
|
|
dumpProtocolOnFailure: valueFromEnv('DEBUGP', false),
|
|
|
|
coverage: process.env.COVERAGE,
|
|
|
|
});
|
|
|
|
|
2020-03-11 18:30:43 -07:00
|
|
|
const filterArgIndex = process.argv.indexOf('--filter');
|
|
|
|
if (filterArgIndex !== -1) {
|
|
|
|
const filter = process.argv[filterArgIndex + 1];
|
|
|
|
testRunner.focusMatchingTests(new RegExp(filter, 'i'));
|
2019-12-18 14:32:20 -08:00
|
|
|
}
|
2019-11-18 18:18:28 -08:00
|
|
|
|
2019-12-18 14:32:20 -08:00
|
|
|
new Reporter(testRunner, {
|
|
|
|
verbose: process.argv.includes('--verbose'),
|
|
|
|
summary: !process.argv.includes('--verbose'),
|
|
|
|
showSlowTests: process.env.CI ? 5 : 0,
|
2020-03-02 14:57:09 -08:00
|
|
|
showMarkedAsFailingTests: 10,
|
2019-12-18 14:32:20 -08:00
|
|
|
});
|
2019-11-18 18:18:28 -08:00
|
|
|
|
2019-12-18 14:32:20 -08:00
|
|
|
// await utils.initializeFlakinessDashboardIfNeeded(testRunner);
|
2020-03-12 17:32:53 -07:00
|
|
|
testRunner.run({ totalTimeout: process.env.CI ? 15 * 60 * 1000 : 0 }).then(result => {
|
2020-01-13 15:30:16 -08:00
|
|
|
process.exit(result.exitCode);
|
2019-12-18 14:32:20 -08:00
|
|
|
});
|
2019-11-18 18:18:28 -08:00
|
|
|
|