我在 Jasmine 框架中开发测试工具时参考此链接触发事件:
I am referred this link to trigger a event when developing a testing tool in Jasmine framework:
http://www.htmlgoodies.com/beyond/javascript/js-ref/testing-dom-events-using-jquery-and-jasmine-2.0.html
在 Jasmine 框架中触发 #DIV_ID 上的点击事件后,我试图获取新应用的 CSS 属性.
I am trying to get the newly applied CSS attribute after triggering a click event on #DIV_ID in Jasmine framework.
我试过这个代码:
spyEvent = spyOnEvent('#DIV_ID', 'click');
$('#DIV_ID').trigger( "click" );
expect('click').toHaveBeenTriggeredOn('#DIV_ID');
expect(spyEvent).toHaveBeenTriggered();
但我收到错误消息:预计事件点击已在#DIV_ID 上触发
谁能帮我解决我的问题.
Anyone help me to resolve my problem.
提前致谢.
你的代码有语法错误:
var spyEvent = spyOnEvent($('#DIV_ID'), 'click');
$('#DIV_ID').trigger( "click" );
expect('click').toHaveBeenTriggeredOn($('#DIV_ID'));
expect(spyEvent).toHaveBeenTriggered();
我希望这行得通.
这篇关于Jasmine 上的错误 - 在 #DIV_ID 上触发了预期的事件点击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
在 javascript 认为文档“准备好"之前,如何让How can I get my jasmine tests fixtures to load before the javascript considers the document to be quot;readyquot;?(在 javascript 认为文档“准备好
jasmine 运行和等待实际上是做什么的?What do jasmine runs and waitsFor actually do?(jasmine 运行和等待实际上是做什么的?)
如何提供模拟文件来更改 <input type='filHow to provide mock files to change event of lt;input type=#39;file#39;gt; for unit testing(如何提供模拟文件来更改 lt;input type=filegt; 的事
如何使用 Jasmine 对链式方法进行单元测试How to unit test a chained method using Jasmine(如何使用 Jasmine 对链式方法进行单元测试)
如何将 $rootScope 注入 AngularJS 单元测试?How do I inject $rootScope into an AngularJS unit test?(如何将 $rootScope 注入 AngularJS 单元测试?)
Jasmine - 如何监视函数中的函数调用?Jasmine - How to spy on a function call within a function?(Jasmine - 如何监视函数中的函数调用?)