我有一个在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单元测试中
发布评论