Skip to content

Commit bfcc09a

Browse files
authored
Fix command args showing as '[object Object]' in reporter. (#4195)
1 parent 2aac3ec commit bfcc09a

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

lib/reporter/index.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,17 @@ class Reporter extends SimplifiedReporter {
238238

239239
static stringifyArgs(args) {
240240
if (Array.isArray(args)) {
241-
return args.map((arg) => arg && arg.toString());
241+
return args.map((arg) => {
242+
let stringifiedArg;
243+
244+
try {
245+
stringifiedArg = JSON.stringify(arg);
246+
} catch {
247+
stringifiedArg = arg && arg.toString();
248+
}
249+
250+
return stringifiedArg;
251+
});
242252
}
243253

244254
return args;

test/src/runner/testReporter.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ describe('testReporter', function() {
324324
assert.ok(Object.keys(command).includes('endTime'));
325325
assert.ok(Object.keys(command).includes('elapsedTime'));
326326
assert.ok(Object.keys(command).includes('result'));
327-
assert.deepEqual(command.args, ['http://localhost']);
327+
assert.deepEqual(command.args, ['"http://localhost"']);
328328
assert.strictEqual(command.status, 'pass');
329329
}
330330
},

0 commit comments

Comments
 (0)