diff --git a/lib/assert.js b/lib/assert.js index 4781f170e359da..05daf6d05ee55a 100644 --- a/lib/assert.js +++ b/lib/assert.js @@ -319,7 +319,15 @@ assert.ifError = function ifError(err) { if (err) throw err; }; // Expose a strict only variant of assert function strict(value, message) { - if (!value) innerFail(value, true, message, '==', strict); + if (!value) { + innerFail({ + actual: value, + expected: true, + message, + operator: '==', + stackStartFn: strict + }); + } } assert.strict = Object.assign(strict, assert, { equal: assert.strictEqual, diff --git a/test/parallel/test-assert.js b/test/parallel/test-assert.js index 949318d65bd8e2..b2debe1d8001ac 100644 --- a/test/parallel/test-assert.js +++ b/test/parallel/test-assert.js @@ -753,6 +753,14 @@ common.expectsError( assert.equal(Object.keys(assert).length, Object.keys(a).length); /* eslint-enable no-restricted-properties */ assert(7); + common.expectsError( + () => assert(), + { + code: 'ERR_ASSERTION', + type: assert.AssertionError, + message: 'undefined == true' + } + ); } common.expectsError(