javascript - Node.js/Jest 测试 - expect(jest.fn()).toBeCalledWith()) 抛出有关“调用次数:0”的错误
问题描述
我对从其他类似的测试创建的一项测试有疑问,问题是这个特定的测试没有通过,我不明白是什么原因造成的。
代码:
it('should call notify on the channel', done => {
httpServicePostMock.mockReturnValue({
subscribe: fn => {
fn({ data: { data: { flightPlans: flightplanss } } });
done();
},
});
const channelNotifyMock = jest.fn();
jest.spyOn(channelGateway, 'notify').mockImplementation(channelNotifyMock);
controller.addSubscriptionByDgsId('clientId', 'stand2');
expect(channelNotifyMock).toBeCalledWith(['clientId'], 'flight_plans/stand2', JSON.stringify(flightplanss));
});
});
错误说调用次数等于 0。
也许有人可以给我一个提示如何解决它?