Skip to content

Commit dd5c4a1

Browse files
dianashkorangejulius
authored andcommitted
feat: add quiet terminal output flag
1 parent e7afcce commit dd5c4a1

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

lib/processArguments.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ function setUpCommander() {
3636
);
3737

3838
var filesHelp = 'The specific test-suite files to execute. ' +
39-
'If not specified, all files in ./test_cases will be run.';
39+
'If not specified, all files in ./test_cases will be run.';
40+
41+
var noPassingHelp = 'If specified, details of all passing tests will be omitted from results';
4042

4143
commander
4244
.usage( '[flags] [file(s)]' )
@@ -54,6 +56,11 @@ function setUpCommander() {
5456
'-t, --test-type <testType>',
5557
util.format( 'The type of tests to run, as specified in test-cases\' `type` property.' )
5658
)
59+
.option(
60+
'-q, --quiet',
61+
noPassingHelp,
62+
false
63+
)
5764
.option( 'files', filesHelp )
5865
.parse( process.argv );
5966

@@ -109,7 +116,8 @@ function getConfig() {
109116
outputGenerator: outputGenerator,
110117
testType: commander.testType,
111118
testSuites: testSuites,
112-
autocomplete: commander.output === 'autocomplete'
119+
autocomplete: commander.output === 'autocomplete',
120+
quiet: commander.quiet
113121
};
114122

115123
return config;

output_generators/terminal.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ var percentageForDisplay = require('../lib/percentageForDisplay');
1414
/**
1515
* Format and print a test result to the terminal.
1616
*/
17-
function prettyPrintResult( result ){
17+
function prettyPrintResult( result, quiet ){
1818
var id = result.testCase.id;
1919
delete result.testCase.in.api_key; // don't display API key
2020

@@ -32,7 +32,9 @@ function prettyPrintResult( result ){
3232
var status = (result.progress === undefined) ? '' : result.progress.inverse + ' ';
3333
switch( result.result ){
3434
case 'pass':
35-
console.log( util.format( ' ✔ %s[%s] "%s"', status, id, testDescription ).green );
35+
if (!quiet) {
36+
console.log(util.format(' ✔ %s[%s] "%s"', status, id, testDescription).green);
37+
}
3638
break;
3739

3840
case 'fail':
@@ -63,7 +65,7 @@ function prettyPrintSuiteResults( suiteResults, config, testSuites ){
6365
console.log();
6466
console.log(testSuite.name.blue);
6567
testSuite.tests.forEach( function(testCase) {
66-
prettyPrintResult( testCase.results[testCase.full_url] );
68+
prettyPrintResult( testCase.results[testCase.full_url], config.quiet );
6769
});
6870
});
6971

0 commit comments

Comments
 (0)