diff --git a/lib/internal/assert/assertion_error.js b/lib/internal/assert/assertion_error.js index 837c37b1221540..e160d6d7e868eb 100644 --- a/lib/internal/assert/assertion_error.js +++ b/lib/internal/assert/assertion_error.js @@ -441,6 +441,7 @@ class AssertionError extends Error { this.generatedMessage = !message; ObjectDefineProperty(this, 'name', { + __proto__: null, value: 'AssertionError [ERR_ASSERTION]', enumerable: false, writable: true, diff --git a/test/parallel/test-assert-fail.js b/test/parallel/test-assert-fail.js index e2003f2ce91da8..37e2087a2fdc72 100644 --- a/test/parallel/test-assert-fail.js +++ b/test/parallel/test-assert-fail.js @@ -1,6 +1,6 @@ 'use strict'; -require('../common'); +const common = require('../common'); const assert = require('assert'); // No args @@ -38,3 +38,7 @@ assert.throws(() => { name: 'TypeError', message: 'custom message' }); + +Object.prototype.get = common.mustNotCall(); +assert.throws(() => assert.fail(''), { code: 'ERR_ASSERTION' }); +delete Object.prototype.get;