Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: table would still be rendered in JSON mode when writing to file #514

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/validate.js
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
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)
})