如何在开玩笑中模拟此错误回调?

时间:2018-06-11 12:56:51

标签: javascript jestjs

send(message) {     
this.test.send(name, message, err => {
     if (err) {
        this.logger.info('error', err);
        return;
      }
      this._logger.info('successfully sent');
   });
  }

我的测试:

testClass.send({value:'嘿'});

expect(sendSpy.mock.calls[0][0]).toEqual(name); // this works 
 expect(sendSpy.mock.calls[0][1]).toEqual(message); // this works 
 expect(sendSpy.mock.calls[0][2]).toBe(expect.anything) // this doesnt.

如何断言错误回调,以便覆盖所有行?

0 个答案:

没有答案