What's the best way to unit test an event being emitted in Nodejs?

后端 未结 7 653
孤独总比滥情好
孤独总比滥情好 2021-02-05 02:12

I\'m writing a bunch of mocha tests and I\'d like to test that particular events are emitted. Currently, I\'m doing this:

  it(\'should emit an some_event\', fun         


        
7条回答
  •  被撕碎了的回忆
    2021-02-05 02:48

    Just stick:

    this.timeout(

    at the top of your it statement:

    it('should emit an some_event', function(done){
        this.timeout(1000);
        myObj.on('some_event',function(){
          assert(true);
          done();
        });`enter code here`
      });
    

提交回复
热议问题