From 92b358ac9482889b3c1b4c2073500be754fac6b1 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Tue, 27 Apr 2021 16:03:54 +0200 Subject: [PATCH] test: fix `common.mustCall` `length` and `name` properties Reassign `name` and `length` properties to the returned function to not break code that relies on it. --- test/common/index.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/test/common/index.js b/test/common/index.js index f40914c94928dd..cee59717f3b099 100644 --- a/test/common/index.js +++ b/test/common/index.js @@ -387,10 +387,25 @@ function _mustCallInner(fn, criteria = 1, field) { mustCallChecks.push(context); - return function() { + const _return = function() { // eslint-disable-line func-style context.actual++; return fn.apply(this, arguments); }; + Object.defineProperties(_return, { + name: { + value: fn.name, + writable: false, + enumerable: false, + configurable: true, + }, + length: { + value: fn.length, + writable: false, + enumerable: false, + configurable: true, + }, + }); + return _return; } function hasMultiLocalhost() {