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(KarmaConf): read CLI browser option to run tests #6166

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
45 changes: 44 additions & 1 deletion spec/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ module.exports = function (config) {
// - Safari (only Mac)
// - PhantomJS
// - IE (only Windows)
browsers: ['PhantomJSCustom'],
browsers: getBrowsers(),

customLaunchers: {
'PhantomJSCustom': {
Expand Down Expand Up @@ -124,3 +124,46 @@ module.exports = function (config) {
singleRun: true
});
};


// Use browser(s) as specified in command arguments.
function getBrowsers() {
var browsers = [];

// Test in each specified browser, if multiple.
// Note: use twice the special argument `--` after `npm test` so that arguments are passed to the downstream `test-nolint` script.
// e.g. `npm test -- -- --ff`
// or directly: `npm run test-nolint -- --ff`
// Currently available:
// - Chrome
// - ChromeCanary
// - Firefox
// - Opera
// - Safari (only Mac)
// - PhantomJS
// - IE (only Windows)
if (isArgv('--chrome')) {
browsers.push('Chrome');
}
if (isArgv('--safari')) {
browsers.push('Safari');
}
if (isArgv('--ff')) {
browsers.push('Firefox');
}
if (isArgv('--ie')) {
browsers.push('IE');
}

// If none is specified, use PhantomJS by default.
// But do not add it if at least another browser is specified, so that we can launch browsers individually.
if (!browsers.length) {
browsers.push('PhantomJSCustom');
}

return browsers;
}

function isArgv(optName) {
return process.argv.indexOf(optName) !== -1;
}