【发布时间】:2020-07-23 15:35:03
【问题描述】:
我试图断言一个函数被调用:
expect(functionA).toHaveBeenCalledWith(xxx, yyyy, true);
我不关心xxx和yyyy是什么,我只关心最后一个参数是否为真。
我如何在 Jasmine 中做到这一点?我试过了:
expect(functionA).toHaveBeenCalledWith(jasmine.objectContaining(true));
虽然 true 不是对象。
我也试过了:
expect(functionA.calls.mostRecent().args[2]).toMatch(true);
但它给了我错误:
Error:<toMatch>:Expected is not a String or a RegExp
我应该如何断言它?我是 Jasmine 的新手,谢谢!
【问题讨论】:
标签: javascript testing jasmine