diff --git a/lib/internal/assert.js b/lib/internal/assert.js index 990065a9378f14..74f7e3f7c053c4 100644 --- a/lib/internal/assert.js +++ b/lib/internal/assert.js @@ -196,7 +196,7 @@ class AssertionError extends Error { } = options; if (message != null) { - super(message); + super(String(message)); } else { if (process.stdout.isTTY) { // Reset on each call to make sure we handle dynamically set environment diff --git a/test/parallel/test-assert.js b/test/parallel/test-assert.js index 59e67810c2c41f..e35ef326c34b86 100644 --- a/test/parallel/test-assert.js +++ b/test/parallel/test-assert.js @@ -640,6 +640,16 @@ common.expectsError( } ); +common.expectsError( + () => assert(false, Symbol('foo')), + { + code: 'ERR_ASSERTION', + type: assert.AssertionError, + generatedMessage: false, + message: 'Symbol(foo)' + } +); + { // Test caching. const fs = process.binding('fs');