1'use strict'; 2 3require('../common'); 4const assert = require('assert'); 5const EventEmitter = require('events'); 6 7const eventsMethods = ['on', 'once', 'removeListener', 'prependOnceListener']; 8 9// Verify that the listener must be a function for events methods 10for (const method of eventsMethods) { 11 assert.throws(() => { 12 const ee = new EventEmitter(); 13 ee[method]('foo', null); 14 }, { 15 code: 'ERR_INVALID_ARG_TYPE', 16 name: 'TypeError', 17 message: 'The "listener" argument must be of type function. ' + 18 'Received null', 19 }, `event.${method}('foo', null) should throw the proper error`); 20} 21