diff --git a/lib/assert.js b/lib/assert.js index 1998246e09c15a..9a684cbe5fd6bf 100644 --- a/lib/assert.js +++ b/lib/assert.js @@ -831,7 +831,7 @@ function expectsError(stackStartFn, actual, error, message) { details += ` (${error.name})`; } details += message ? `: ${message}` : '.'; - const fnType = stackStartFn.name === 'rejects' ? 'rejection' : 'exception'; + const fnType = stackStartFn === assert.rejects ? 'rejection' : 'exception'; innerFail({ actual: undefined, expected: error, @@ -878,7 +878,7 @@ function expectsNoError(stackStartFn, actual, error, message) { if (!error || hasMatchingError(actual, error)) { const details = message ? `: ${message}` : '.'; - const fnType = stackStartFn.name === 'doesNotReject' ? + const fnType = stackStartFn === assert.doesNotReject ? 'rejection' : 'exception'; innerFail({ actual, @@ -998,7 +998,7 @@ function internalMatch(string, regexp, message, fn) { 'regexp', 'RegExp', regexp ); } - const match = fn.name === 'match'; + const match = fn === assert.match; if (typeof string !== 'string' || RegExpPrototypeTest(regexp, string) !== match) { if (message instanceof Error) {