茉莉花间谍“期待(xxx)。notToHaveBeenCalled()
Jasmine spy "expect(xxx).notToHaveBeenCalled()
非常感谢那些如此迅速拯救我的人。问题的实质是我没有意识到我应该查看 "matchers" 的文档,而查看 "expect" 并不能解决我的问题。
我正在使用 Jasmine 3.0(对它来说非常新!)并尝试验证间谍在特定条件下是否看到对目标的零调用。我想我可能会为此使用 count()
行为,但我正在努力弄清楚我应该使用什么语法。
我试过了
spyOn(target, 'action').and.callThrough();
target.triggeringAction();
expect(target.action).count().toBe(0);
但 Jasmine 报告 TypeError: expect(...).count is not a function
。
我没有看到任何 expect(...).toNotHaveBeenCalled()
,我不确定接下来要看哪里。
您可以使用 expect(target.action).toHaveBeenCalledTimes(0);
这个也可以expect(target.action).not.toHaveBeenCalled();
非常感谢那些如此迅速拯救我的人。问题的实质是我没有意识到我应该查看 "matchers" 的文档,而查看 "expect" 并不能解决我的问题。
我正在使用 Jasmine 3.0(对它来说非常新!)并尝试验证间谍在特定条件下是否看到对目标的零调用。我想我可能会为此使用 count()
行为,但我正在努力弄清楚我应该使用什么语法。
我试过了
spyOn(target, 'action').and.callThrough();
target.triggeringAction();
expect(target.action).count().toBe(0);
但 Jasmine 报告 TypeError: expect(...).count is not a function
。
我没有看到任何 expect(...).toNotHaveBeenCalled()
,我不确定接下来要看哪里。
您可以使用 expect(target.action).toHaveBeenCalledTimes(0);
这个也可以expect(target.action).not.toHaveBeenCalled();