@@ -7,16 +7,18 @@ var constants = require('../../tasks/util/constants');
77var isCI = ! ! process . env . CIRCLECI ;
88var 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'
@@ -53,6 +55,7 @@ if(argv.info) {
5355 ' - `--Chrome` (alias `--chrome`): run test in (our custom) Chrome browser' ,
5456 ' - `--Firefox` (alias `--FF`, `--firefox`): run test in (our custom) Firefox browser' ,
5557 ' - `--nowatch (dflt: `false`, `true` on CI)`: run karma w/o `autoWatch` / multiple run mode' ,
58+ ' - `--failFast` (dflt: `false`): exit karma upon first test failure' ,
5659 ' - `--verbose` (dflt: `false`): show test result using verbose reporter' ,
5760 ' - `--tags`: run only test with given tags (using the `jasmine-spec-tags` framework)' ,
5861 ' - `--width`(dflt: 1035): set width of the browser window' ,
@@ -100,11 +103,14 @@ if(isFullSuite) {
100103
101104var pathToShortcutPath = path . join ( __dirname , '..' , '..' , 'tasks' , 'util' , 'shortcut_paths.js' ) ;
102105var pathToStrictD3 = path . join ( __dirname , '..' , '..' , 'tasks' , 'util' , 'strict_d3.js' ) ;
103- var pathToMain = path . join ( __dirname , '..' , '..' , 'lib' , 'index.js' ) ;
104106var pathToJQuery = path . join ( __dirname , 'assets' , 'jquery-1.8.3.min.js' ) ;
105107var pathToIE9mock = path . join ( __dirname , 'assets' , 'ie9_mock.js' ) ;
106108var 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+
108114function func ( config ) {
109115 // level of logging
110116 // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
@@ -118,7 +124,7 @@ function func(config) {
118124 //
119125 // See https://github.com/karma-runner/karma/commit/89a7a1c#commitcomment-21009216
120126 func . defaultConfig . browserConsoleLogOptions = {
121- level : 'log '
127+ level : 'debug '
122128 } ;
123129
124130 config . set ( func . defaultConfig ) ;
@@ -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,16 +241,18 @@ 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
239- }
247+ } ,
248+
249+ // e.g. when a test file does not container a given spec tags
250+ failOnEmptyTestSuite : false
240251} ;
241252
242253func . defaultConfig . preprocessors [ pathToCustomMatchers ] = [ 'browserify' ] ;
243254
244- if ( isFullSuite ) {
245- func . defaultConfig . files . push ( pathToJQuery ) ;
246- func . defaultConfig . preprocessors [ testFileGlob ] = [ 'browserify' ] ;
247- } else if ( isBundleTest ) {
255+ if ( isBundleTest ) {
248256 switch ( basename ( testFileGlob ) ) {
249257 case 'requirejs' :
250258 // browserified custom_matchers doesn't work with this route
@@ -271,14 +279,7 @@ if(isFullSuite) {
271279 break ;
272280 }
273281} else {
274- // Add lib/index.js to non-full-suite runs,
275- // to make sure the registry is set-up correctly.
276- func . defaultConfig . files . push (
277- pathToJQuery ,
278- pathToMain
279- ) ;
280-
281- func . defaultConfig . preprocessors [ pathToMain ] = [ 'browserify' ] ;
282+ func . defaultConfig . files . push ( pathToJQuery ) ;
282283 func . defaultConfig . preprocessors [ testFileGlob ] = [ 'browserify' ] ;
283284}
284285
@@ -291,9 +292,4 @@ if(argv.Chrome) browsers.push('_Chrome');
291292if ( argv . Firefox ) browsers . push ( '_Firefox' ) ;
292293if ( browsers . length === 0 ) browsers . push ( '_Chrome' ) ;
293294
294- // add verbose reporter if specified
295- if ( argv . verbose ) {
296- func . defaultConfig . reporters . push ( 'verbose' ) ;
297- }
298-
299295module . exports = func ;
0 commit comments