Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions lib/batch.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

'use strict'

const util = require('util');

const _ = require('lodash')
const async = require('async')
const debug = require('debug')('vows:batch')
Expand Down Expand Up @@ -165,7 +167,9 @@ class Batch {
const err = calledWith[0]
const results = calledWith.slice(1)

debug(`Results for topic of '${this.title}': ${err}, ${results.join(', ')}`)
// Need to call util.inspect ourselves in case objects have a null prototype
// ES6 modules in particular do this.
debug(`Results for topic of '${this.title}': ${err}, ${results.map(util.inspect).join(', ')}`)

this.runTests(err, results)
this.report.successes = _.keys(this.tests).length - this.report.failures
Expand Down Expand Up @@ -265,7 +269,7 @@ class Batch {
if (_.size(this.tests) > 0) {
const args = _.concat([err], results)

debug(`Passing args '${args.join(', ')}' to tests for batch '${this.title}'`)
debug(`Passing args '${args.map(util.inspect).join(', ')}' to tests for batch '${this.title}'`)

for (const name in this.tests) {
const test = this.tests[name]
Expand Down Expand Up @@ -307,7 +311,7 @@ class Batch {
} else {
const batchArgs = _.concat(_.clone(results), args)

debug(`Passing args '${batchArgs.join(', ')}' to batches for '${this.title}'`)
debug(`Passing args '${batchArgs.map(util.inspect).join(', ')}' to batches for '${this.title}'`)

const runBatch = (sub, callback) => {
sub.run(batchArgs, (err, report) => {
Expand Down
32 changes: 32 additions & 0 deletions test/test-null-prototype-topic.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// test-static-topic.js -- A topic that has a null prototype
//
// Copyright 2018 Fuzzy.ai <evan@fuzzy.ai>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

'use strict'

const vows = require('../lib/index')
const assert = vows.assert

vows.describe('topic that has a null prototype')
.addBatch({
'When we use a topic with a null prototype': {
topic: Object.create(null),
'it works' (err, data) {
assert.ifError(err)
assert.isObject(data)
}
}
})
.export(module)