From 8e8aa6e721131bd12336580ba8f1db6b853b4a0f Mon Sep 17 00:00:00 2001 From: AJ Jordan Date: Thu, 19 Feb 2026 00:54:43 -0500 Subject: [PATCH 1/2] Handle objects with null prototypes as topics --- lib/batch.js | 10 +++++++--- test/test-null-prototype-topic.js | 32 +++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 test/test-null-prototype-topic.js diff --git a/lib/batch.js b/lib/batch.js index 9816ac28..4223cf57 100644 --- a/lib/batch.js +++ b/lib/batch.js @@ -18,6 +18,8 @@ 'use strict' +const util = require('node:util'); + const _ = require('lodash') const async = require('async') const debug = require('debug')('vows:batch') @@ -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 @@ -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] @@ -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) => { diff --git a/test/test-null-prototype-topic.js b/test/test-null-prototype-topic.js new file mode 100644 index 00000000..4d931e12 --- /dev/null +++ b/test/test-null-prototype-topic.js @@ -0,0 +1,32 @@ +// test-static-topic.js -- A topic that has a null prototype +// +// Copyright 2018 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) From eb01ed73bd1a5b36d35873304af89a0f29ef018f Mon Sep 17 00:00:00 2001 From: AJ Jordan Date: Fri, 20 Feb 2026 20:26:51 -0500 Subject: [PATCH 2/2] Fix import name for Node 8 --- lib/batch.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/batch.js b/lib/batch.js index 4223cf57..be538168 100644 --- a/lib/batch.js +++ b/lib/batch.js @@ -18,7 +18,7 @@ 'use strict' -const util = require('node:util'); +const util = require('util'); const _ = require('lodash') const async = require('async')