在webpack通过Karma测试运行器将它们组合在一起后,我想在一堆模块上运行我的测试,但是每当我运行我的测试时,Karma都会说,"Error:Cannotfindmodule"hello.js"athttp://localhost:9877/base/src/hello.spec.js?d301966ffc1330826574d9d8fff5a644c3390c68:47"我有一个规范文件:vara=require('hello.js');describe("atesttest",function(){it("humperdinktest",function(){expect(a
我正在尝试对Angular.js服务进行单元测试,并且需要对从模拟服务(使用Jasmine)返回的promise设置期望。我正在使用karma单元测试框架。相关代码片段如下://Ican'tfigureouthowtodotheequivalentofa$scope.$digesthere.varloginStatusPromise=FacebookService.getFacebookToken();loginStatusPromise.then(function(token){expect(false).toBeTruthy();//Ifthistestpasses,thereis
目标:为waCarousel指令范围变量编写一个通过测试:self.awesomeThings。当self.awsomeThings.length.toBe(3)为真时,期望此测试通过?问题:如何正确编写此测试?而是如何注入(inject)指令Controller?指令:angular.module('carouselApp').directive('waCarousel',function(){return{templateUrl:'../../../views/carousel/wa.carousel.html',controller:function($scope){varsel
我正在尝试开始使用karma和Jasmine。我已经安装了它们。我相信Karma可以找到我的JavaScript文件。当我运行karmastart时,我的浏览器打开并显示:Karmav0.12.23-connectedIE11.0.0(Windows8.1)isidleFirefox29.0.0(Windows8.1)isidleChrome37.0.2062(Windows8.1)isidle我将一个JavaScript文件添加到我认为Karma正在监视的位置:it('yshouldhavealengthof1',function(){vary='1';expect(y.length
我有一个奇怪的问题。每当我尝试测试某些东西但测试失败时,它总是显示第9行的堆栈跟踪。我正在使用AngularJS以及Jasmine和Karma。我发现它不依赖于浏览器。错误如下所示:TypeError:'undefined'isnotanobject(evaluating'newgoogle.maps.LatLng')at/Users/user1/project1/test_ctrl.js:9at/Users/user1/project1/spec/test_ctrl_spec.js:170因此,它告诉我测试在第170行失败(这是正确的),但错误原因在我的test_ctrl.js中,行
我正在尝试使用karma配置自动测试。我的文件结构如下/assests/css/font/img/js/collection/lib/model/plugin/spec/viewtest-main.jsmain.js/templatesindex.htmlkarma.conf.jskarma.conf.js:module.exports=function(config){config.set({//basepaththatwillbeusedtoresolveallpatterns(eg.files,exclude)basePath:'',//frameworkstouse//avai
当由于错误(如语法错误)导致Karma无法运行测试时,Karma会发出这样的警告:INFO[karma]:Karmav0.12.31serverstartedathttp://localhost:9876/INFO[launcher]:StartingbrowserPhantomJSINFO[PhantomJS1.9.8(Linux)]:ConnectedonsocketWT-AsaXZq4odkQe2DgZJwithid10861626WARN[web-server]:404:/undefinedhttp%3A%2F%2Flocalhost%3A9876%2Fbase%2Ftests
在一些httpajax请求后在代码中手动引导应用程序时,我在测试angularjs应用程序(karma、jasmine)时遇到问题。angular.module("app",[]);angular.element(document).ready(function(){angular.bootstrap(document,["app"]);});我的jasmine规范中也有以下代码beforeEach(module('app'));当我运行我的规范时,我总是有同样的错误Error:[$injector:modulerr]FailedtoinstantiatemoduleappduetoE
我正在尝试将karma和requirejs拼凑在一起。但发现一个大问题找不到任何答案。我有一个使用requirejs的项目,我使用qunit作为它的测试框架。他们在karma进来之前工作得很好。关注Karmarequirejsinstruction后,我得到一个错误,找不到合适的解决方案。karma版本为0.12.6错误是:UncaughtError:Mismatchedanonymousdefine()module....如何让它们协同工作?这是我的文件结构projectroot||----\src||||----\demo||||||----hello.js||||----\tes
几天来,我一直在尝试设置karma以与Require.js一起工作(然后再将require与angular一起使用),这令人非常沮丧。这是我的文件树在这个例子中的样子:$tree.|--public||--index.html||--src||--app.js|`--main.js|--config||--karma.conf.js|--lib||--jquery.js||--require.js|`--underscore.js|--src||--app.js|`--main.js`--test|--appSpec.js`--test-main.js注意事项:我正在处理的这个存储库是