Skip to content

Commit

Permalink
fix: table would still be rendered in JSON mode when writing to file (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
10xLaCroixDrinker authored Mar 12, 2024
1 parent ac8169c commit f1af1c3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ module.exports = function validateOpts (opts, cbPassedIn) {
// fill in defaults after
opts = defaultOpts(opts)

if (opts.json === true) {
opts.renderProgressBar = opts.renderResultsTable = opts.renderLatencyTable = false
}

if (opts.requests) {
if (opts.requests.some(r => !isValidFn(r.setupRequest))) {
return new Error('Invalid option setupRequest, please provide a function (or file path when in workers mode)')
Expand Down
18 changes: 18 additions & 0 deletions test/validate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,3 +228,21 @@ test('validateOpts should return an error when forever is used with workers', {
t.ok(result instanceof Error)
t.equal(result.message, 'Using `forever` option isn\'t currently supported with workers')
})

test('validateOpts should not set render options by default', (t) => {
t.plan(3)

const result = validateOpts({ url: 'http://localhost' })
t.equal(result.renderProgressBar, undefined)
t.equal(result.renderResultsTable, undefined)
t.equal(result.renderLatencyTable, undefined)
})

test('validateOpts should disable render options when json is true', (t) => {
t.plan(3)

const result = validateOpts({ url: 'http://localhost', json: true })
t.equal(result.renderProgressBar, false)
t.equal(result.renderResultsTable, false)
t.equal(result.renderLatencyTable, false)
})

0 comments on commit f1af1c3

Please sign in to comment.