How to test event listeners using QUnit
问题 I'm using pure Javascript (no JQuery) and I'm trying to get QUnit to test my function that is only invoked via an event, i.e. it's an event listener. So the function I wish to test is of the form: (function() { function the_one_i_want_to_test() { // do stuff } window.addEventListener('load', function() { var some_element = ...; some_element.addEventListener('click', the_one_i_want_to_test); }); })(); I know I could expose the function to test it, but it is only ever used as an event listener