diff --git a/lib/internal/console/constructor.js b/lib/internal/console/constructor.js index 44fa0f32d76..0a5849d524f 100644 --- a/lib/internal/console/constructor.js +++ b/lib/internal/console/constructor.js @@ -430,9 +430,14 @@ const consoleMethods = { this.error(err.stack); }, + // Defined by: https://console.spec.whatwg.org/#assert assert(expression, ...args) { if (!expression) { - args[0] = `Assertion failed${args.length === 0 ? '' : `: ${args[0]}`}`; + if (args.length && typeof args[0] === 'string') { + args[0] = `Assertion failed: ${args[0]}`; + } else { + ArrayPrototypeUnshift(args, 'Assertion failed'); + } // The arguments will be formatted in warn() again ReflectApply(this.warn, this, args); } diff --git a/test/message/console_assert.js b/test/message/console_assert.js new file mode 100644 index 00000000000..14976312820 --- /dev/null +++ b/test/message/console_assert.js @@ -0,0 +1,5 @@ +'use strict'; + +require('../common'); + +console.assert(false, Symbol('hello')); diff --git a/test/message/console_assert.out b/test/message/console_assert.out new file mode 100644 index 00000000000..259d18fa5cf --- /dev/null +++ b/test/message/console_assert.out @@ -0,0 +1 @@ +Assertion failed* Symbol(hello)