1'use strict'; 2 3// This tests that AsyncHooks throws an error if bad parameters are passed. 4 5require('../common'); 6const assert = require('assert'); 7const async_hooks = require('async_hooks'); 8const nonFunctionArray = [null, -1, 1, {}, []]; 9 10['init', 'before', 'after', 'destroy', 'promiseResolve'].forEach( 11 (functionName) => { 12 nonFunctionArray.forEach((nonFunction) => { 13 assert.throws(() => { 14 async_hooks.createHook({ [functionName]: nonFunction }); 15 }, { 16 code: 'ERR_ASYNC_CALLBACK', 17 name: 'TypeError', 18 message: `hook.${functionName} must be a function`, 19 }); 20 }); 21 }); 22