且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何检查是否在Jasmine中使用特定选择器调用了jQuery,$?

更新时间:2023-11-08 22:01:40

看着jQuery脚本(版本3.5.1),我发现处理选择器的函数是 $.fn.init

Looking at the jQuery script (version 3.5.1), I found that the function that handles the selector is $.fn.init

 jQuery.fn.init = function( selector, context, root ) {...}

在#3133行.

因此您的茉莉花期望为:

expect($.fn.init).toHaveBeenCalledWith('#test1', undefined, jasmine.anything());


您可以忽略一些参数.参考