• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3// This tests that using falsy values in createHook throws an error.
4
5require('../common');
6const assert = require('assert');
7const async_hooks = require('async_hooks');
8
9[0, 1, false, true, null, 'hello'].forEach((badArg) => {
10  const hookNames = ['init', 'before', 'after', 'destroy', 'promiseResolve'];
11  hookNames.forEach((field) => {
12    assert.throws(() => {
13      async_hooks.createHook({ [field]: badArg });
14    }, {
15      code: 'ERR_ASYNC_CALLBACK',
16      name: 'TypeError',
17      message: `hook.${field} must be a function`
18    });
19  });
20});
21