Skip to content

Commit 562787e

Browse files
BridgeARMylesBorins
authored andcommitted
assert: fix strict regression
Using `assert()` or `assert.ok()` resulted in a error since a refactoring. Refs: #17582 Backport-PR-URL: #23223 PR-URL: #17903 Refs: #17582 Reviewed-By: Anatoli Papirovski <[email protected]> Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent f2af930 commit 562787e

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

lib/assert.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,15 @@ assert.ifError = function ifError(err) { if (err) throw err; };
783783

784784
// Expose a strict only variant of assert
785785
function strict(value, message) {
786-
if (!value) innerFail(value, true, message, '==', strict);
786+
if (!value) {
787+
innerFail({
788+
actual: value,
789+
expected: true,
790+
message,
791+
operator: '==',
792+
stackStartFn: strict
793+
});
794+
}
787795
}
788796
assert.strict = Object.assign(strict, assert, {
789797
equal: assert.strictEqual,

test/parallel/test-assert.js

+8
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,14 @@ common.expectsError(
711711
assert.equal(Object.keys(assert).length, Object.keys(a).length);
712712
/* eslint-enable no-restricted-properties */
713713
assert(7);
714+
common.expectsError(
715+
() => assert(),
716+
{
717+
code: 'ERR_ASSERTION',
718+
type: assert.AssertionError,
719+
message: 'undefined == true'
720+
}
721+
);
714722
}
715723

716724
common.expectsError(

0 commit comments

Comments
 (0)