mirror of
https://github.com/nodejs/node.git
synced 2026-11-24 21:50:36 -05:00
assert: fix strict regression
Using `assert()` or `assert.ok()` resulted in a error since a refactoring. Refs: https://github.com/nodejs/node/pull/17582 Backport-PR-URL: https://github.com/nodejs/node/pull/19230 PR-URL: https://github.com/nodejs/node/pull/17903 Refs: https://github.com/nodejs/node/pull/17582 Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
1 parent
ebd60fa505
commit
f96ea47cf5
2 files changed
+17
-1
No files matched your search
+9
-1
@@ -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,
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in new issue
Block a user