如何将jquery添加到jasmine / angularjs单元测试中

编程入门 行业动态 更新时间:2024-10-26 00:27:56
本文介绍了如何将jquery添加到jasmine / angularjs单元测试中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个在plain angular.js代码上构建的项目。我们用茉莉花创造单元测试。但是现在我们需要获取一些第三方组件(来自Angular-Bootstrap的一些指令),这里面也是纯粹的angular.js,但是为了测试那些组件,使用了一些jQuery代码和方法调用。现在很多第三方测试失败了,例如 [object]没有方法'触发'和类似的东西

I have a project which is builded on plain angular.js code. We creates unittest with jasmine. But now we need to grab some 3rd party components (some directives from Angular-Bootstrap), which is also pure angular.js inside, but for testing that components some jQuery code and methods calls used. And now a lot of 3rd party tests failed with exception like [object] had no method 'trigger' and stuff like that

所以我的问题是如何将jquery包含在我的测试中,以使第三方unitests有效。 我用Karma运行测试。

So my question is how to include jquery to my tests, to make 3rd party unitests valid. I run tests with Karma.

推荐答案

只需将jquery.js包含在文件数组中的Karma配置中作为第一项。

Just include jquery.js to Karma's config in files array as the first item.

module.exports = function(config) { config.set({ // list of files / patterns to load in the browser files: [ 'path/to/jquery.js', 'path/to/angular.js' //..rest files ], //rest karma options }); };

更多推荐

如何将jquery添加到jasmine / angularjs单元测试中

本文发布于:2023-11-14 11:30:10,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1587094.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何将   单元   测试中   jasmine   jquery

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!