jasmine专题提供jasmine的最新资讯内容,帮你更好的了解jasmine。
我想提供简单的常量值,如姓名,电子邮件等,以便在我的茉莉花单元测试中使用. 这里也提出了类似的问题:AngularJS + Karma: reuse a mock service when unit testing directives or controllers 在c#中,我将创建一个静态类来保存模拟数据的小片段.然后我可以在整个单元测试中使用这些值,如下所示: static class Sa
上下文 我有一个组件.在其中,ngOnInit函数调用组件的另一个函数来检索用户List.我想制作两个系列的小提琴: >首先测试ngOnInit是否被正确触发并填充用户列表 >第二次我想测试我的刷新函数,它也调用getUserList() 当我调用fixture.detectChanges()时,使用ngOnInit触发器的第一个测试正常工作. 问题 我的问题是在测试刷新功能时:一旦我调用fixt
我正在尝试测试一些使用< a ui-sref ='someState'> link< / a>的视图.链接到我的应用程序中的其他状态.在我的测试中,我触发了对这些元素的点击,如下所示: element.find('a').click() 如果状态切换到某个状态,我该如何测试?在我的控制器中使用$state时会很容易: // in my view <a ng-click="goTo('someSta
如何在角度2中测试私有函数? class FooBar { private _status: number; constructor( private foo : Bar ) { this.initFooBar(); } private initFooBar(){ this.foo.bar( "data" );
我有一个使用Angular Translate( https://github.com/PascalPrecht/angular-translate)的应用程序.翻译通过浏览器在应用程序中运行良好,但当我尝试测试任何控制器时,我得到错误:意外请求:GET locale / locale-en.json.我如何对我的控制器进行单元测试,因为translate在启动时会对语言文件进行GET请求? 我正
我想在Angular 2单元测试中更改输入字段的值. <input type="text" class="form-control" [(ngModel)]="abc.value" /> 我不能只更改ngModel,因为abc对象是私有的: private abc: Abc = new Abc(); 在Angular 2测试中,我可以模拟用户在输入字段中输入的内容,以便使用用户在单元测试中输入的内
我的项目从独立到Web,我们的新WebSite正在AngularJS中创建,因此Protractor是为Test Automation选择的工具. 我想整合Typescript与Jasmine和Node的依赖关系,以便我不会得到诸如此类的错误 cannot find name Describe cannot find name it cannot find name Expect 任何人都可以告诉
大多数Angular教程都讨论了使用Protractor进行端到端测试来测试编译模板是否按预期出现.我想知道是否有可能完成单元测试. 大多数关于在单元测试中引用HTML代码的教程都描述了在测试中编译自己编写的代码,例如,以确保正确访问指令: describe('some function', function () { it('should do something', inject(func
我一直在试图单独测试依赖于AngularFireAuth的服务(AuthService). 我试图找到一种方法来模拟或高举Observable AngularFireAuth.authState而不是实际与Firebase交谈的服务. 这是我的测试规范: import { inject, TestBed } from '@angular/core/testing'; import { Angul
我试图用Jasmine测试名为MyDirective的结构指令.使用的Angular版本是RC5. // Part of the MyDirective class @Directive({selector: '[myDirective]'}) export class MyDirective { constructor(protected templateRef: TemplateRe
我有一个工厂来执行一个获取请求,我想测试.不幸的是业界测试告诉我,$httpBackend没有定义回应. AngularJs 1.2.14, 茉莉2.0, 羯磨0.12.0 这是我要测试的模块: var appFactory = angular.module('appFactory', []); appFactory.factory('boxListService', function($htt
我有以下指令来自动对焦一个字段: .directive('ngAutofocus', function ($timeout) { return { restrict: 'A', link: function (scope, elm) { $timeout(function () { elm[0]
给定一个附加到$routeChangeSuccess事件的处理程序来更新$rootScope上的title属性: $rootScope.$on('$routeChangeSuccess', function (event, current, previous) { $rootScope.title = 'My title'; }); 在单元测试中,我希望执行路由更改会更新标题属性: it('s
我有一个带有局部变量的控制器 function IndexCtrl($scope) { var pagesById = []; loadPages(); // snip function loadPages() { // pagesById gets populated } // snip } 我想测试pageById是否正确填充,但我不知道如何从我的()获取
我通过gulp运行业务测试用例如下: gulp.task('unit-test-karma', function () { return gulp.src(filePaths.libraryPaths.concat(filePaths.codePathsVerbose.concat(filePaths.testPaths).concat(filePaths.htmlPaths).conca
我正在使用茉莉花创建一个这样的间谍: beforeEach(inject(function ($injector) { $rootScope = $injector.get('$rootScope'); $state = $injector.get('$state'); $controller = $injector.get('$controller'); soc
在茉莉花/羯磨中努力进行单元测试.我有一个具有服务依赖关系的控制器,该服务具有另一个服务依赖关系.我没有按类型(指令,服务等)组织我的模块,而是通过功能(布局,summaryView等)组织我的模块. 这是架构: angular.module('myApp', ['ngResource', 'myApp.base', 'myApp.layout','myApp.common']); angular
我对这个很新(有角度,茉莉花,testacular),我有这个代码(我简化了一点,只留下重要的): //my_module.js angular.module('my_module', ['my_data']) .config([...]); .controller('my_controller', ['$scope', 'my_data', function($scope, my_da
有没有人知道如何获得一个无头浏览器,如Chutzpah的Visual Studio测试适配器,以允许一个指令访问其.html模板文件? Chutzpah使用PhantomJS作为无头浏览器,似乎限制了我的选择. 我使用的是Chutzpah测试适配器2.5和AngularJS 1.2.0-r.2. 我得到错误: Unexpected request: GET myApp/directives/tem
我刚刚将Angular2从RC3升级到RC4 … import { expect, it, iit, xit, describe, ddescribe, xdescribe, beforeEach, beforeEachProviders, withProviders, async, inject } from '@angular/core/testing'; 在我的单元测试中,我