Skip to content

Commit 834bf33

Browse files
committed
chore(karma): make karma fail silently if no browsers detected
Users can run with KARMA_MANUAL=1 if they need to run karma with no browsers
1 parent 8bba48b commit 834bf33

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

karma.conf.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ if (process.env.SAUCE_ACCESS_KEY && process.env.SAUCE_USERNAME) {
2525
job = process.env.TRAVIS_JOB_NUMBER;
2626
build = `travis@${ process.env.TRAVIS_JOB_NUMBER }`;
2727
startConnect = true;
28-
} else {
28+
} else if (!process.env.KARMA_MANUAL) {
2929
browsers = [];
3030
frameworks.push('detectBrowsers');
3131
}
@@ -68,6 +68,20 @@ module.exports = function configureKarma(config) {
6868
detectBrowsers: {
6969
enabled: true,
7070
usePhantomJS: false,
71+
postDetection(detectedBrowsers) {
72+
if (detectedBrowsers.length === 0) {
73+
/* eslint-disable no-console, no-process-exit */
74+
console.log('**********************************');
75+
console.log('**************WARNING*************');
76+
console.log('**********************************');
77+
console.log('Karma has been unable to detect a browser on your system');
78+
console.log('Karma will now exit(0). If you have a browser you\'d like to test');
79+
console.log('please run `env KARMA_MANUAL=1 karma`, and manually load up a browser');
80+
process.exit(0);
81+
/* eslint-enable */
82+
}
83+
return detectedBrowsers;
84+
},
7185
},
7286
sauceLabs: {
7387
testName: packageJson.name,

0 commit comments

Comments
 (0)