Skip to content

Commit

Permalink
test fallback to ChromeCanary/Chromium/PhantomJS in macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
teabyii committed Apr 6, 2017
1 parent b4ebabd commit 18805a0
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion karma.conf.js
Expand Up @@ -48,7 +48,7 @@ module.exports = function (config) {
},
reporters: ['spec'],
colors: true,
browsers: [osName() === 'macOS Sierra' ? 'Chrome' : 'PhantomJS'], // This is the default browser to run, locally
browsers: [osName() === 'macOS Sierra' ? getBrowserInMacOS() : 'PhantomJS'], // This is the default browser to run, locally
logLevel: config.LOG_INFO,
client: {
mocha: {
Expand Down Expand Up @@ -167,3 +167,26 @@ function addSauceTests (cfg) {
cfg.captureTimeout = 120000;
cfg.browserNoActivityTimeout = 20000;
}

function getBrowserInMacOS () {
var browsers = ['Chrome', 'ChromeCanary', 'Chromium'];
var paths = [
'/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
'/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary',
'/Applications/Chromium.app/Contents/MacOS/Chromium'
];
var browserPath;

for (var i = 0; i < browsers.length; i++) {
browserPath = paths[i];

try {
fs.accessSync(browserPath);
return browsers[i];
} catch (e) {
// nothing
}
}

return 'PhantomJS';
}

0 comments on commit 18805a0

Please sign in to comment.