summaryrefslogtreecommitdiff
path: root/test/common/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/common/index.js')
-rw-r--r--test/common/index.js21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/common/index.js b/test/common/index.js
index dd29927759..e93c73820a 100644
--- a/test/common/index.js
+++ b/test/common/index.js
@@ -718,6 +718,26 @@ function runWithInvalidFD(func) {
printSkipMessage('Could not generate an invalid fd');
}
+// A helper function to simplify checking for ERR_INVALID_ARG_TYPE output.
+function invalidArgTypeHelper(input) {
+ if (input == null) {
+ return ` Received ${input}`;
+ }
+ if (typeof input === 'function' && input.name) {
+ return ` Received function ${input.name}`;
+ }
+ if (typeof input === 'object') {
+ if (input.constructor && input.constructor.name) {
+ return ` Received an instance of ${input.constructor.name}`;
+ }
+ return ` Received ${util.inspect(input, { depth: -1 })}`;
+ }
+ let inspected = util.inspect(input, { colors: false });
+ if (inspected.length > 25)
+ inspected = `${inspected.slice(0, 25)}...`;
+ return ` Received type ${typeof input} (${inspected})`;
+}
+
module.exports = {
allowGlobals,
buildType,
@@ -735,6 +755,7 @@ module.exports = {
hasIntl,
hasCrypto,
hasMultiLocalhost,
+ invalidArgTypeHelper,
isAIX,
isAlive,
isFreeBSD,