我的Javascript函数是functionInvestment(params){varparams=params||{};this.stock=params.stock;this.shares=params.sharesthis.cost=params.cost};我的规范是describe("Investment",function(){beforeEach(function(){this.stock=newStock();this.investment=newInvestment({stock:this.stock,shares:100cost:2000});});it("sh
我定义了一个自定义事件。我想用Jasmine来窥探它。但我遇到的问题是,当我使用spyOn监视该事件时,它失败了。当我监视某些功能时,它工作正常。这是我尝试过的:describe("Test:",function(){it("Expectseventwillbespied:",function(){vareventSpy=spyOn(window,'myEvent').andCallThrough();expect(eventSpy).toHaveBeenCalled();//Alsotriedthis://expect(eventSpy).not.toHaveBeenCalled()
我认为Vim保存文件和Karma重新运行我的Jasmine单元测试之间存在竞争条件。以下是演示症状的四个测试运行序列(我chop了错误日志中的极长路径):$karmastartkarma.conf.js--auto-watch[...snipalotofcodingandtestrunning...]PhantomJS1.6(Linux)LOG:'Runningtestsat2013-08-14T08:19:57.252Z'PhantomJS1.6(Linux):Executed4of4SUCCESS(0.307secs/0.013secs)PhantomJS1.6(Linux)LOG
我已经使用npm安装了jasmine-node。我的项目目录结构如下:|-lib\|-taxCalc.js|-spec\|-taxCalc.spec.coffee|-taxCalc.spec.js|-src\|-taxCalc.coffee当我使用以下命令(对于CoffeeScript)从根文件夹运行jasmine-node时:jasmine-node--coffee--verbosespecFinishedin0.015seconds0tests,0assertions,0failures如果我运行JavaScript版本,则相同。如果我明确指向spec文件测试运行正常:jasmin
我有很多几乎相同的测试。为了DRY和可扫描性,我想将测试抽象为一个函数,然后使用一些参数调用该函数。然后该函数将调用它并将规范添加到套件中。它似乎可以工作,除了规范不会以与其他规范相同的方式运行,并且beforeEach不会在公共(public)函数中定义的规范之前被调用。define(['modules/MyModule','jasmine/jasmine'],function(MyModule){describe('myModule',function(){functioncommonTests(params){it('shouldpassthistestOK',function(
我正在尝试编写一个单元测试,断言正确的变量正在从Angular-UIBootstrap发送到ui.bootstrap.modal的resolve属性组件。这是我目前所拥有的://Controllerangular.module('app').controller('WorkflowListCtrl',function($scope,$modal){//Setuptheeditcallbacktoopenamodal$scope.edit=function(name){varmodalInstance=$modal.open({templateUrl:'partials/editWork
我已经尝试并试图让它发挥作用。documentation充其量是简洁的:resetExpectations();-重置所有请求预期,但保留所有后端定义。通常,当您想要重用$httpBackendmock的相同实例时,您会在多阶段测试期间调用resetExpectations。每次我的第二个请求被调用时,我的结果总是有第一个结果的数据。看看这个fiddlehttp://jsfiddle.net/tbwn1gt0/2/我在第一次刷新后重置期望,然后设置新的期望/结果,然后再次刷新以产生不正确的数据。//---SPECS-------------------------varurl='/pa
在其中一个测试中,我们需要断言3个元素之一存在。目前我们正在使用protractor.promise.all()和Array.reduce()来完成它:vartitle=element(by.id("title")),summary=element(by.id("summary")),description=element(by.id("description"));protractor.promise.all([title.isPresent(),summary.isPresent(),description.isPresent()]).then(function(arrExists
我正在尝试开始使用Node.JS在服务器端测试JavaScript我正在使用grunt,和grunt-jasmine-node,但我无法让它运行我的测试。它只是记录PSC:\Development\NET\Source\jsn>gruntRunning"jasmine_node"taskundefinedFinishedin0.001seconds0tests,0assertions,0failuresDone,withouterrors.这是我的Gruntfile.jsmodule.exports=function(grunt){grunt.initConfig({pkg:grunt
我正在尝试加载一些固定装置以进行测试。至此我已经准备好了一个json文件。我确实设置了应该加载特定文件的beforeEach函数,但出现错误:Error:Fixturecouldnotbeloaded:tests/license_filter/license_test_data.json(status:error,message:undefined)部分测试函数:beforeEach(function(){jasmine.getFixtures().fixturesPath='tests/license_filter';loadFixtures('license_test_data.j