【发布时间】:2021-04-27 04:48:48
【问题描述】:
我的代码:
$('#test1').val('string1');
我可以测试是否已使用 'string1' 调用了 val。
spyOn($.fn, 'val');
expect($.fn.val).toHaveBeenCalledWith('string1');
但我想测试是否使用特定的选择器调用了 $。我希望能够做到这一点。
expect($.fn).toHaveBeenCalledWith('#test1');
【问题讨论】:
标签: javascript jquery unit-testing jasmine