Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(infrastructure): Don't run Chrome headless during SL runs #3210

Merged
merged 3 commits into from
Jul 25, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 23 additions & 19 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,15 @@ const webpackConfig = require('./webpack.config')[0];
const USING_TRAVISCI = Boolean(process.env.TRAVIS);
const USING_SL = Boolean(process.env.SAUCE_USERNAME && process.env.SAUCE_ACCESS_KEY);

const SL_LAUNCHERS = {
/*
* Chrome (headless)
*/

const LOCAL_LAUNCHERS = {
/** See https://github.com/travis-ci/travis-ci/issues/8836#issuecomment-348248951 */
'ChromeHeadlessNoSandbox': {
base: 'ChromeHeadless',
// See https://github.com/travis-ci/travis-ci/issues/8836#issuecomment-348248951
flags: ['--no-sandbox'],
},
};

const SAUCE_LAUNCHERS = {
/*
* Chrome (desktop)
*/
Expand Down Expand Up @@ -136,6 +134,9 @@ const SL_LAUNCHERS = {
// },
};

const getLaunchers = () => USING_SL ? SAUCE_LAUNCHERS : LOCAL_LAUNCHERS;
const getBrowsers = () => Object.keys(getLaunchers());

module.exports = function(config) {
config.set({
basePath: '',
Expand All @@ -150,12 +151,12 @@ module.exports = function(config) {
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
browsers: determineBrowsers(),
browsers: getBrowsers(),
browserDisconnectTimeout: 40000,
browserNoActivityTimeout: 120000,
captureTimeout: 240000,
concurrency: USING_SL ? 4 : Infinity,
customLaunchers: SL_LAUNCHERS,
customLaunchers: getLaunchers(),

coverageReporter: {
dir: 'coverage',
Expand Down Expand Up @@ -200,23 +201,26 @@ module.exports = function(config) {
},
});

// See https://github.com/karma-runner/karma-sauce-launcher/issues/73
if (USING_TRAVISCI) {
config.set({
sauceLabs: {
if (USING_SL) {
const sauceLabsConfig = {
username: process.env.SAUCE_USERNAME,
accessKey: process.env.SAUCE_ACCESS_KEY,
};

if (USING_TRAVISCI) {
// See https://github.com/karma-runner/karma-sauce-launcher/issues/73
Object.assign(sauceLabsConfig, {
testName: 'Material Components Web Unit Tests - CI',
tunnelIdentifier: process.env.TRAVIS_JOB_NUMBER,
username: process.env.SAUCE_USERNAME,
accessKey: process.env.SAUCE_ACCESS_KEY,
startConnect: false,
},
});
}

config.set({
sauceLabs: sauceLabsConfig,
// Attempt to de-flake Sauce Labs tests on TravisCI.
transports: ['polling'],
browserDisconnectTolerance: 3,
});
}
};

function determineBrowsers() {
return USING_SL ? Object.keys(SL_LAUNCHERS) : ['ChromeHeadlessNoSandbox'];
}