Skip to content

Commit 8c7a0e6

Browse files
committed
improve karma reporters defaults
- use spec reporter on CI - use dots on local full-suite runs - use progress on targeted local runs - show skipped runs on CI by default, not locally - add report-progress, report-spec, report-dots CLI args to override defaults
1 parent 7e789b3 commit 8c7a0e6

File tree

1 file changed

+35
-11
lines changed

1 file changed

+35
-11
lines changed

test/jasmine/karma.conf.js

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ var argv = minimist(process.argv.slice(4), {
1010
string: ['bundleTest', 'width', 'height'],
1111
'boolean': [
1212
'info',
13-
'nowatch', 'failFast', 'verbose', 'randomize',
14-
'Chrome', 'Firefox', 'IE11'
13+
'nowatch', 'failFast', 'randomize',
14+
'Chrome', 'Firefox', 'IE11',
15+
'verbose', 'showSkipped', 'report-progress', 'report-spec', 'report-dots'
1516
],
1617
alias: {
1718
'Chrome': 'chrome',
@@ -24,11 +25,12 @@ var argv = minimist(process.argv.slice(4), {
2425
'default': {
2526
info: false,
2627
nowatch: isCI,
27-
failFast: false,
28-
verbose: false,
2928
randomize: false,
29+
failFast: false,
3030
width: '1035',
31-
height: '617'
31+
height: '617',
32+
verbose: false,
33+
showSkipped: isCI
3234
}
3335
});
3436

@@ -64,12 +66,15 @@ if(argv.info) {
6466
' - `--IE11` (alias -- `ie11`)`: run test in IE11 browser',
6567
' - `--nowatch (dflt: `false`, `true` on CI)`: run karma w/o `autoWatch` / multiple run mode',
6668
' - `--failFast` (dflt: `false`): exit karma upon first test failure',
67-
' - `--verbose` (dflt: `false`): show test result using verbose reporter',
68-
' - `--showSkipped` (dflt: `false`): show tests that are skipped',
6969
' - `--randomize` (dflt: `false`): randomize test ordering (useful to detect bad test teardown)',
7070
' - `--tags`: run only test with given tags (using the `jasmine-spec-tags` framework)',
7171
' - `--width`(dflt: 1035): set width of the browser window',
7272
' - `--height` (dflt: 617): set height of the browser window',
73+
' - `--verbose` (dflt: `false`): show test result using verbose reporter',
74+
' - `--showSkipped` show tests that are skipped',
75+
' - `--report-progress`: use *progress* reporter',
76+
' - `--report-spec`: use *spec* reporter',
77+
' - `--report-dots`: use *dots* reporter',
7378
'',
7479
'For info on the karma CLI options run `npm run test-jasmine -- --help`'
7580
].join('\n'));
@@ -119,7 +124,26 @@ var pathToCustomMatchers = path.join(__dirname, 'assets', 'custom_matchers.js');
119124
var pathToUnpolyfill = path.join(__dirname, 'assets', 'unpolyfill.js');
120125
var pathToMathJax = path.join(constants.pathToDist, 'extras', 'mathjax');
121126

122-
var reporters = ((isFullSuite && !argv.tags) || argv.showSkipped) ? ['dots', 'spec'] : ['progress'];
127+
var reporters = [];
128+
if(argv['report-progress'] || argv['report-spec'] || argv['report-dots']) {
129+
if(argv['report-progress']) reporters.push('progress');
130+
if(argv['report-spec']) reporters.push('spec');
131+
if(argv['report-dots']) reporters.push('dots');
132+
} else {
133+
if(isCI) {
134+
reporters.push('spec');
135+
} else {
136+
if(isFullSuite) {
137+
reporters.push('dots');
138+
} else {
139+
reporters.push('progress');
140+
}
141+
}
142+
}
143+
144+
var hasSpecReporter = reporters.indexOf('spec') !== -1;
145+
146+
if(!hasSpecReporter && argv.showSkipped) reporters.push('spec');
123147
if(argv.verbose) reporters.push('verbose');
124148

125149
function func(config) {
@@ -262,9 +286,9 @@ func.defaultConfig = {
262286
// use 'karma-spec-reporter' to log info about skipped specs
263287
specReporter: {
264288
suppressErrorSummary: true,
265-
suppressFailed: true,
266-
suppressPassed: true,
267-
suppressSkipped: false,
289+
suppressFailed: !hasSpecReporter,
290+
suppressPassed: !hasSpecReporter,
291+
suppressSkipped: !argv.showSkipped,
268292
showSpecTiming: false
269293
}
270294
};

0 commit comments

Comments
 (0)