Skip to content

Commit f96ea47

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: #19230 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 ebd60fa commit f96ea47

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
@@ -319,7 +319,15 @@ assert.ifError = function ifError(err) { if (err) throw err; };
319319

320320
// Expose a strict only variant of assert
321321
function strict(value, message) {
322-
if (!value) innerFail(value, true, message, '==', strict);
322+
if (!value) {
323+
innerFail({
324+
actual: value,
325+
expected: true,
326+
message,
327+
operator: '==',
328+
stackStartFn: strict
329+
});
330+
}
323331
}
324332
assert.strict = Object.assign(strict, assert, {
325333
equal: assert.strictEqual,

test/parallel/test-assert.js

+8
Original file line numberDiff line numberDiff line change
@@ -753,6 +753,14 @@ common.expectsError(
753753
assert.equal(Object.keys(assert).length, Object.keys(a).length);
754754
/* eslint-enable no-restricted-properties */
755755
assert(7);
756+
common.expectsError(
757+
() => assert(),
758+
{
759+
code: 'ERR_ASSERTION',
760+
type: assert.AssertionError,
761+
message: 'undefined == true'
762+
}
763+
);
756764
}
757765

758766
common.expectsError(

0 commit comments

Comments
 (0)