diff --git a/bin/run.js b/bin/run.js index 87976c580..4f2357d51 100755 --- a/bin/run.js +++ b/bin/run.js @@ -127,6 +127,7 @@ const constructDefaultArgs = _ => { timeout: +process.env.TAP_TIMEOUT || defaultTimeout, color: !!colorSupport.level, reporter: null, + reporterOptions: {}, files: [], grep: [], grepInvert: false, @@ -282,6 +283,10 @@ const parseArgs = (args, options) => { options.reporter = val || args[++i] continue + case '--reporter-options': + options.reporterOptions = JSON.parse(val || args[++i]) + continue + case '--gc': case '-gc': case '--expose-gc': options.nodeArgs.push('--expose-gc') continue @@ -595,9 +600,9 @@ const setupTapEnv = options => { const globFiles = files => files.reduce((acc, f) => acc.concat(f === '-' ? f : glob.sync(f, { nonull: true })), []) -const makeReporter = options => - new (require('tap-mocha-reporter'))(options.reporter) - +const makeReporter = options => { + return new (require('tap-mocha-reporter'))(options.reporter, {}, options.reporterOptions) +} const stdinOnly = options => { // if we didn't specify any files, then just passthrough // to the reporter, so we don't get '/dev/stdin' in the suite list. diff --git a/bin/usage.txt b/bin/usage.txt index e01bfa0df..ef1357c56 100644 --- a/bin/usage.txt +++ b/bin/usage.txt @@ -62,6 +62,11 @@ Options: Available reporters: @@REPORTERS@@ + --reporter-options= Configure the specified reporter with a + JSON value. For example, you could use + '{"reporter": {"open": "(", "close": ")"}}' + to customize the progress reporter. + -o Send the raw TAP output to the specified --output-file= file. Reporter output will still be printed to stdout, but the file will diff --git a/docs/cli/index.md b/docs/cli/index.md index 2d0234dac..6d0eafcec 100644 --- a/docs/cli/index.md +++ b/docs/cli/index.md @@ -74,6 +74,11 @@ Options: landing list markdown min nyan progress silent spec tap xunit + --reporter-options= Configure the specified reporter with a + JSON value. For example, you could use + `{"reporter": {"open": "(", "close": ")"}}` + to customize the progress reporter. + -o Send the raw TAP output to the specified --output-file= file. Reporter output will still be printed to stdout, but the file will diff --git a/docs/reporting/index.md b/docs/reporting/index.md index 29e091db8..d7bcdbdb1 100644 --- a/docs/reporting/index.md +++ b/docs/reporting/index.md @@ -86,3 +86,11 @@ The following options are available: - xunit XML output popular in .NET land. + +You can pass options to those reporters using `--reporter-options` +with a JSON value. For example: + +``` +--reporter=progress +--reporter-options='{"reporter": {"open": "(", "close": ")"}}' +``` diff --git a/package.json b/package.json index c429d7c92..3a725df52 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "signal-exit": "^3.0.0", "source-map-support": "^0.5.6", "stack-utils": "^1.0.0", - "tap-mocha-reporter": "^3.0.7", + "tap-mocha-reporter": "FIXME: bump to contain https://github.com/tapjs/tap-mocha-reporter/pull/49 once it lands", "tap-parser": "^7.0.0", "tmatch": "^4.0.0", "trivial-deferred": "^1.0.1",