草庐IT

generator-karma

全部标签

javascript - fixture 不会在 Karma 中加载

我已经尝试了很多方法,但在运行Karma时似乎无法加载固定装置。我试过使用html2js和karma-jasmine-jquery—我倾向于后者,但无论哪个将我的固定装置加载到DOM中,我都会接受)—但据我所知,当我的测试运行时,它没有被加载并附加到DOM。我的目录结构很简单:img/↳mac.png↳link.png↳pocketwatch.pngjs/↳spriteloader.js↳spriteloader.spec.jskarma/↳imagelist.fix.html↳karma.conf.jsGruntfile.coffeeindex.htmlgrunt.config.co

javascript - Babel [karma-babel-preprocessor] 不为 Karma 测试转换 ES6->ES5

我们已经安装了karma,它使用mocha和chai进行测试。我们正在尝试使用karma-babel-preprocessor将babel直接集成到karma中,以将我们的ES6文件转换为ES5以运行。单独使用mocha与babel一起工作,即mocha测试命令,但我们尝试使用karma而不是它不起作用。karma.conf.js片段:frameworks:['mocha','chai'],//preprocessmatchingfilesbeforeservingthemtothebrowser//availablepreprocessors:https://npmjs.org/br

javascript - 使用 Gradle 运行 karma ?

我有Jasmine单元测试,我想运行它并获取Istanbul代码覆盖率报告。我可以运行一个命令行脚本来在Jenkins中运行Karma,但是使用我的build.gradle执行所有内容会很好。是否可以使用Gradle运行Karma?我搜索过谷歌,但似乎找不到解决方案。谢谢 最佳答案 我通过在build.gradle文件中创建并运行一个可执行任务解决了这个问题:taskkarma(type:Exec){commandLine'karma','start','--single-runtrue'}

javascript - karma 提示 'Module is not available'

直到几天前,我的单元测试运行良好,我的代码在浏览器中运行完美。然后我在添加一个名为“profile”的stub模块后注意到了这一点:INFO[karma]:Karmav0.12.24serverstartedathttp://localhost:9876/INFO[launcher]:StartingbrowserPhantomJSINFO[PhantomJS1.9.7(MacOSX)]:Connectedonsocket7W-0vnkWZaWxYYtwFrhTwithid9336780PhantomJS1.9.7(MacOSX)ERRORError:[$injector:nomod]

javascript - 如何调试使用 Testacular (Karma) 运行的 Jasmine 规范?

我有一个带有Jasmine规范的小项目,我使用Testacular作为我的测试运行器。我不明白如何调试应用程序代码或规范代码。当我尝试在Chrome开发工具中设置断点时,它不会在下次运行规范时命中,因为它每次都会使用新的查询字符串加载文件。到目前为止,我发现的最好的方法是使用console.log(),但我更愿意使用Chrome开发工具断点。(我正在使用VisualStudio2012进行开发。)谢谢 最佳答案 Testacular不是用于调试的最佳工具。它的强大之处在于它可以在多个浏览器中运行您的测试,并且执行速度非常快,并且可以

javascript - Angular 1.3 + ui-router + generator-ng-poly 嵌入嵌套(?) View 不起作用

我是Angular、ui-router和generator-ng-poly的新手并希望有人可以帮助解决可能是简单语法问题。我正在为一个新项目使用generator-ng-poly,并使用ui-router和HTML从“深度示例”开始使用基于Angular1.3的应用程序。首先,我创建了一个“home”模块,然后在其中创建了一个“header”模块。所以……yong-poly:modulehomeyong-poly:modulehome/header这给了我这两个Controller:应用程序/home/home.js(function(){'usestrict';/*@ngdocobj

javascript - 在 karma 环境中的 Blob 中使用 importsScripts

我正在使用karma和jasmine进行我的一个小项目。我的目标浏览器是chrome32。我正在尝试在我通过blob实例化的webworker中导入脚本,如下所示:describeAsyncAppliPersephone("WhentheapplicationprojecttoDOM",function(){it("itshouldcallthefunctionofDomProjectionintheprojectassociatedwithitsevent",function(){vareventSentBack={eventType:'testReceived',headers:{

javascript - 流: Dynamically generate string union types?

假设我有一个流类型Suit,我想将它组合成另一种名为Card的类型。//types.jstypeSuit=|"Diamonds"|"Clubs"|"Hearts"|"Spades";typeCard={...suit:Suit,...}与其直接在suit.js中对Suit字符串进行硬编码,不如根据JavaScript原语(数组)动态生成Suit类型?说...//constants.jsconstSUITS=['Diamonds','Clubs','Hearts','Spades'];通过这种方式,西装只需定义一次,并且可以在JavaScript结构中定义,该结构将在应用程序的其他部分中

javascript - 调用 karma 测试时未定义 Angular 错误

我确定这与angular-mock.js有关,但我不知道我需要做什么,因为一切似乎都很好。我只是使用angular-seed应用程序的默认设置。请帮忙解决问题karma.conf.jsmodule.exports=function(config){config.set({basePath:'../',files:['bower_components/angular/angular.js','bower_components/angular-route/angular-route.js','bower_components/angular-mocks/angular-mocks.js',

javascript - 使用 Angular.js + UI 路由器进行 Karma 测试

我想知道如何使用Karma测试Angular.js+UI路由器?我定义了以下状态:其中有两个resolve,它们获取一些数据并为Controller准备数据。(来自Ember背景,这很有意义。)$stateProvider.state('users',{resolve:{getData:function(User){returnUser.query().$promise},stateModels:function(getData){varmodels={}models.users=getDatareturnmodels}},url:'/',templateUrl:'/views/use