Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 689671b

Browse files
committed
add --failFast cli option to karma runner
- which makes karma exits upon first test failure
1 parent bdf468e commit 689671b

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

package-lock.json

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@
136136
"karma": "^3.0.0",
137137
"karma-browserify": "^5.3.0",
138138
"karma-chrome-launcher": "^2.0.0",
139+
"karma-fail-fast-reporter": "^1.0.5",
139140
"karma-firefox-launcher": "^1.0.1",
140141
"karma-jasmine": "^1.1.2",
141142
"karma-jasmine-spec-tags": "^1.0.1",

test/jasmine/karma.conf.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,18 @@ var constants = require('../../tasks/util/constants');
77
var isCI = !!process.env.CIRCLECI;
88
var argv = minimist(process.argv.slice(4), {
99
string: ['bundleTest', 'width', 'height'],
10-
'boolean': ['info', 'nowatch', 'verbose', 'Chrome', 'Firefox'],
10+
'boolean': ['info', 'nowatch', 'failFast', 'verbose', 'Chrome', 'Firefox'],
1111
alias: {
1212
'Chrome': 'chrome',
1313
'Firefox': ['firefox', 'FF'],
1414
'bundleTest': ['bundletest', 'bundle_test'],
15-
'nowatch': 'no-watch'
15+
'nowatch': 'no-watch',
16+
'failFast': 'fail-fast'
1617
},
1718
'default': {
1819
info: false,
1920
nowatch: isCI,
21+
failFast: false,
2022
verbose: false,
2123
width: '1035',
2224
height: '617'
@@ -105,6 +107,10 @@ var pathToJQuery = path.join(__dirname, 'assets', 'jquery-1.8.3.min.js');
105107
var pathToIE9mock = path.join(__dirname, 'assets', 'ie9_mock.js');
106108
var pathToCustomMatchers = path.join(__dirname, 'assets', 'custom_matchers.js');
107109

110+
var reporters = (isFullSuite && !argv.tags) ? ['dots', 'spec'] : ['progress'];
111+
if(argv.failFast) reporters.push('fail-fast');
112+
if(argv.verbose) reporters.push('verbose');
113+
108114
function func(config) {
109115
// level of logging
110116
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
@@ -154,7 +160,7 @@ func.defaultConfig = {
154160
// See note in CONTRIBUTING.md about more verbose reporting via karma-verbose-reporter:
155161
// https://www.npmjs.com/package/karma-verbose-reporter ('verbose')
156162
//
157-
reporters: (isFullSuite && !argv.tags) ? ['dots', 'spec'] : ['progress'],
163+
reporters: reporters,
158164

159165
// web server port
160166
port: 9876,
@@ -235,6 +241,8 @@ func.defaultConfig = {
235241
suppressPassed: true,
236242
suppressSkipped: false,
237243
showSpecTiming: false,
244+
// use 'karma-fail-fast-reporter' to fail fast w/o conflicting
245+
// with other karma plugins
238246
failFast: false
239247
},
240248

@@ -294,9 +302,4 @@ if(argv.Chrome) browsers.push('_Chrome');
294302
if(argv.Firefox) browsers.push('_Firefox');
295303
if(browsers.length === 0) browsers.push('_Chrome');
296304

297-
// add verbose reporter if specified
298-
if(argv.verbose) {
299-
func.defaultConfig.reporters.push('verbose');
300-
}
301-
302305
module.exports = func;

0 commit comments

Comments
 (0)