diff --git a/lib/internal/assert.js b/lib/internal/assert.js index b5eb88c93b61db..e403fd4b60e06a 100644 --- a/lib/internal/assert.js +++ b/lib/internal/assert.js @@ -6,4 +6,10 @@ function assert(value, message) { } } +function fail(message) { + require('assert').fail(message); +} + +assert.fail = fail; + module.exports = assert; diff --git a/test/parallel/test-internal-assert.js b/test/parallel/test-internal-assert.js index b34657d3a67f84..4fd443864bdac7 100644 --- a/test/parallel/test-internal-assert.js +++ b/test/parallel/test-internal-assert.js @@ -13,3 +13,5 @@ internalAssert(true, 'fhqwhgads'); assert.throws(() => { internalAssert(false); }, assert.AssertionError); assert.throws(() => { internalAssert(false, 'fhqwhgads'); }, { code: 'ERR_ASSERTION', message: 'fhqwhgads' }); +assert.throws(() => { internalAssert.fail('fhqwhgads'); }, + { code: 'ERR_ASSERTION', message: 'fhqwhgads' });