summaryrefslogtreecommitdiff
path: root/test/parallel/test-util-inspect.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/parallel/test-util-inspect.js')
-rw-r--r--test/parallel/test-util-inspect.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/parallel/test-util-inspect.js b/test/parallel/test-util-inspect.js
index 7fb677d495..40bc363877 100644
--- a/test/parallel/test-util-inspect.js
+++ b/test/parallel/test-util-inspect.js
@@ -696,6 +696,28 @@ assert.strictEqual(util.inspect(-5e-324), '-5e-324');
Error.stackTraceLimit = tmp;
}
+// Prevent enumerable error properties from being printed.
+{
+ let err = new Error();
+ err.message = 'foobar';
+ let out = util.inspect(err).split('\n');
+ assert.strictEqual(out[0], 'Error: foobar');
+ assert(out[out.length - 1].startsWith(' at '));
+ // Reset the error, the stack is otherwise not recreated.
+ err = new Error();
+ err.message = 'foobar';
+ err.name = 'Unique';
+ Object.defineProperty(err, 'stack', { value: err.stack, enumerable: true });
+ out = util.inspect(err).split('\n');
+ assert.strictEqual(out[0], 'Unique: foobar');
+ assert(out[out.length - 1].startsWith(' at '));
+ err.name = 'Baz';
+ out = util.inspect(err).split('\n');
+ assert.strictEqual(out[0], 'Unique: foobar');
+ assert.strictEqual(out[out.length - 2], " name: 'Baz'");
+ assert.strictEqual(out[out.length - 1], '}');
+}
+
// Doesn't capture stack trace.
{
function BadCustomError(msg) {