草庐IT

javascript - Jasmine 测试用例未在已编译的 Typescript 中定义内启动

我正在处理一个测试项目,我正在编写一个纯JavascriptJasmineKarma设置来测试预编译的Typescript设置。但是,我无法启动测试用例。我可以在控制台中看到来自已编译typescript的控制台消息正常运行,但它根本不会启动测试脚本。请注意,这来自AngularApp,但这整个部分来自一个在没有Angular2的情况下制作和编译的部分。没有错误消息,除此之外显示运行了0/0测试,并且没有“component/to/test”的时间戳。在test.spec.js文件中,我有define("testName",["component/to/test"],function(

javascript - 为什么我的 Jasmine 规范是 'No specs found'

我的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

javascript - 如何监视 Jasmine 中的自定义事件?

我定义了一个自定义事件。我想用Jasmine来窥探它。但我遇到的问题是,当我使用spyOn监视该事件时,它失败了。当我监视某些功能时,它工作正常。这是我尝试过的:describe("Test:",function(){it("Expectseventwillbespied:",function(){vareventSpy=spyOn(window,'myEvent').andCallThrough();expect(eventSpy).toHaveBeenCalled();//Alsotriedthis://expect(eventSpy).not.toHaveBeenCalled()

javascript - 为什么 jasmine-node 找不到我的规范文件?

我已经使用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

javascript - 是否可以在一个函数中定义一个 Jasmine 规范并且仍然有 beforeEach 应用于它?

我有很多几乎相同的测试。为了DRY和可扫描性,我想将测试抽象为一个函数,然后使用一些参数调用该函数。然后该函数将调用它并将规范添加到套件中。它似乎可以工作,除了规范不会以与其他规范相同的方式运行,并且beforeEach不会在公共(public)函数中定义的规范之前被调用。define(['modules/MyModule','jasmine/jasmine'],function(MyModule){describe('myModule',function(){functioncommonTests(params){it('shouldpassthistestOK',function(

javascript - 让 Jasmine 在服务器端运行

我正在尝试开始使用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

javascript - jquery-jasmine - 夹具无法加载

我正在尝试加载一些固定装置以进行测试。至此我已经准备好了一个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

javascript - Jasmine Controller 测试,预计 spy 已被调用

我在AngularJSController中定义了一个方法,该方法在初始化时调用。我想使用Jasmine("jasmine-core":"^2.3.4","karma":"^0.12.37")测试它。我遵循了Internet上的一些教程和StackOverflow问题,但找不到正确的答案。请看一下这段代码:ControllerusersAddUserController:(function(){'usestrict';angular.module('app.users.addUser').controller('usersAddUserController',['$scope','us

javascript - AngularJs Jasmine 单元测试中的 $httpBackend

我无法让我的单元测试正常工作。我有一个开始为空的$scope数组,但应该用$http.get()填充。在真实环境中,数组中大约有15个左右的对象,但对于我的单元测试,我只抓取了2个。对于单元测试,我有:expect($scope.stuff.length).toBe(2);但jasmine的错误是:Expected0tobe2.这是我的controller.js:$scope.stuff=[];$scope.getStuff=function(){varurl=site.root+'api/stuff';$http.get(url).success(function(data){$sc

javascript - AngularJS Jasmine isolateScope() 返回未定义

我希望从我的help-button指令中的隔离范围中得到一些东西。it('shouldcontainproperscope,dependingonattributes',function(){varel=compile('')(scope);scope.$digest();console.log("el:"+el);console.log('Isolatedscope:'+el.isolateScope());..});--在每次测试之前beforeEach(inject(function($compile,$rootScope,$injector){compile=$compile;