Skip to content

Commit

Permalink
Fix command args showing as '[object Object]' in reporter. (#4195)
Browse files Browse the repository at this point in the history
  • Loading branch information
garg3133 committed May 5, 2024
1 parent 2aac3ec commit bfcc09a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion lib/reporter/index.js
Expand Up @@ -238,7 +238,17 @@ class Reporter extends SimplifiedReporter {

static stringifyArgs(args) {
if (Array.isArray(args)) {
return args.map((arg) => arg && arg.toString());
return args.map((arg) => {
let stringifiedArg;

try {
stringifiedArg = JSON.stringify(arg);
} catch {
stringifiedArg = arg && arg.toString();
}

return stringifiedArg;
});
}

return args;
Expand Down
2 changes: 1 addition & 1 deletion test/src/runner/testReporter.js
Expand Up @@ -324,7 +324,7 @@ describe('testReporter', function() {
assert.ok(Object.keys(command).includes('endTime'));
assert.ok(Object.keys(command).includes('elapsedTime'));
assert.ok(Object.keys(command).includes('result'));
assert.deepEqual(command.args, ['http://localhost']);
assert.deepEqual(command.args, ['"http://localhost"']);
assert.strictEqual(command.status, 'pass');
}
},
Expand Down

0 comments on commit bfcc09a

Please sign in to comment.