我正在开发一个gem,我已经安装了Jasminehttps://github.com/pivotal/jasmine-gem/我所有需要的JS文件都在我的list文件中,位于app/assets/javascripts/application.js//=requireunderscore//=requirebackbone//=require_tree.//vendor//=require_tree.//custom//=require_tree.//templates//=require_tree.//models//=require_tree.//collections//=req
我正在尝试使用Karma、Jasmine和Webpack测试(覆盖)我的TypeScript应用程序。通过以下,我能够成功运行测试,但无法正确生成覆盖率。我正在使用karma-remap-coverage(https://github.com/sshev/karma-remap-coverage),它看起来很简单。它看起来好像发生了一些有趣的事情(而且我得到了某种覆盖率报告)但是在这里和那里进行了一些调整,数字发生了巨大变化,我永远无法真正加载源map。这是基本设置:我有一个src目录,其中包含10个.ts文件。目前只有一个有相应的.spec文件。spec文件非常简单,足以证明我可以运
我现在卡住了一段时间,试图设置和运行单元测试。我有一个AngularJS前端加载了针对生产优化的RequireJS和r.js,所以它很好地放在一个文件中。这行得通!执行单元测试是行不通的。到目前为止,这没什么特别的,只是从教程中复制了一个starter。tests/user/user.test.js:define(['angular','angular-mocks','app'],function(angular,app){describe('Unit:UserController',function(){beforeEach(module('user.app'));it('shoul
在我的示例应用程序中,我像这样测试运行器收藏夹Controller:varmodule=angular.module('AngularSampleApp',[]);varFavoritesController=module.controller('FavoritesController',functionfavoritesController($scope){$scope.phones=[{'name':'NexusS','snippet':'FastjustgotfasterwithNexusS.'},{'name':'MotorolaXOOM™withWi-Fi','snippet
我设置了grunt来运行node.jsJasmine测试。出于某种原因,使用此配置,结果总是显示双倍的测试。这是我的配置:我正在使用jasmine-node插入grunt。/spec/some-spec.js:varmyModule=require('../src/myModule.js');describe('test',function(){it('works',function(done){setTimeout(function(){expect(1).toBe(1);done();},100);});});Gruntfile.js:module.exports=function
我正在创建一个在其link函数中调用服务的元素指令:app.directive('depositList',['depositService',function(depositService){return{templateUrl:'depositList.html',restrict:'E',scope:{status:'@status',title:'@title'},link:function(scope){scope.depositsInfo=depositService.getDeposits({status:scope.status});}};}]);目前该服务很简单:ap
我正在尝试编写一个单元测试来验证是否调用了$rootScope.$broadcast('myApiPlay',{action:'play'});。这是myapi.jsangular.module('myApp').factory('MyApi',function($rootScope){varapi={};api.play=function(){$rootScope.$broadcast('myApiPlay',{action:'play'});}returnapi;});这是我的单元测试:describe('Service:MyApi',function(){//loadtheser
我正在努力使用Karma+Jasmine测试AngularJS工厂。我无法将我的工厂注入(inject)OfficerValidationService变量。我做错了什么?注意:文件加载正确工厂:'usestrict';angular.module('darthvader').factory('OfficerValidationService',[function(){varOfficerValidationService={};OfficerValidationService.something=function(){returntrue;};returnOfficerValidat
一直在尝试简单的异步测试。安装jasmine-nodenpminstall-gjasmine-node然后编写一个简单的模块并测试。简单的模块。//weather.jsexports.get=function(city,callback){callback(city);};和一个测试套件。//weather-spec.jsvarlist=require("../modules/weather");describe("WeatherForecast",function(data){it('shouldgetweatherforLondon,UK',function(){list.get(
我有一个Node.js应用程序,它有一个main-process.js和一个child-process.js。main-process.js看起来像这样:varchildProcess=require('child_process');varjob=childProcess.spawn('node',["child-process.js"],{detached=true,stdio:['ipc']});我的child-process.js执行一些任务并通知父进程它的状态,它使用:exports.init=function(){//someprocessinghereprocess.se