jasmine

Angular 2 with jasmine: test component with injected service

烂漫一生 提交于 2019-12-02 10:36:45
I can't manage to create a simple jasmine test for my Angular 2 project. This is what I'm trying to do: Component to test (based on a service): @Component({ providers: [AccountService], selector: "account", templateUrl: "app/account/account.component.html", }) export class AccountComponent implements OnInit { public accounts: Account[]; public error: string; constructor(private accountService: AccountService) {} public ngOnInit(): any { this.getAccounts(); } public getAccounts() { this.accountService.getAccounts() .then( accounts => this.accounts = accounts, error => this.error = error ); } }

getting 404 error when generating allure report in protractor using allure command line tool

半世苍凉 提交于 2019-12-02 10:08:11
问题 I am trying to generate allure report in protractor for the first time, To generate allure report I am using jasmine allure reporter:1.0.2 and allure-commandline tool:2.7.0 versions In my conf file I have added the code for generating xml results in a specific folder and then I am using allure-commandline tool to generate html report which gets generated in a folder named "Allure-report" in the project home directory, but now when I open the index.html file generated by using allure

How to test browserify project using karma/jasmine

帅比萌擦擦* 提交于 2019-12-02 08:32:03
问题 I'm totally new to the concept of testing, and i need one solid example on how to do it in my project: I have a gulp file goes like this (Not all of it, just the important portions) gulp.task('bundle', function() { gulp.src('public/angular-app/main.js') .pipe(browserify({ debug: true })) .pipe(gulp.dest('public/min-js')); }); This is a slight portion of my main.js: 'use strict'; angular.module('myApp', [ 'ui.router', 'ui.bootstrap', 'ngSanitize', 'ngFx', ... ], ['$interpolateProvider',

How to test browserify project using karma/jasmine

眉间皱痕 提交于 2019-12-02 07:29:14
I'm totally new to the concept of testing, and i need one solid example on how to do it in my project: I have a gulp file goes like this (Not all of it, just the important portions) gulp.task('bundle', function() { gulp.src('public/angular-app/main.js') .pipe(browserify({ debug: true })) .pipe(gulp.dest('public/min-js')); }); This is a slight portion of my main.js: 'use strict'; angular.module('myApp', [ 'ui.router', 'ui.bootstrap', 'ngSanitize', 'ngFx', ... ], ['$interpolateProvider', function($interpolateProvider) { $interpolateProvider.startSymbol('{{'); $interpolateProvider.endSymbol('}}')

d3js unit testing removal of elements

家住魔仙堡 提交于 2019-12-02 07:27:28
问题 I am using jasmine to unit test some interactions in a d3.js chart. I have been using d3.timerFlush() to complete the executions of animations. This works great for when entering new elements or updating attribute, and I am able to accurately test the new values. However, I am having a hard time getting it to remove elements. I have a method like this: exit() { let arcs = svg.selectAll("path.arc"); arcs.transition().duration(1000) .attrTween("d", function(d, i) { return vm._arcTween(this, d)

Angular: How to spy on $element.on

﹥>﹥吖頭↗ 提交于 2019-12-02 07:02:34
I have a directive which does something like this in its link function angular.module('myApp') .directive('barFoo', function() { return { restrict: 'E', link: function (scope, element) { element.on('click', ....); } }; }); Now I would like to verify in my unit test that it calls on correctly element = angular.element('<bar-foo></bar-foo>'); $compile(element)(scope); spyOn(element, 'on'); ... expect(element.on).toHaveBeenCalled(); It tells me the spy is not called. From what I've found on the web, angular/jquery creates a new wrapper around the DOM element every time. Meaning the the element

AngularJS 2014-10-22

风流意气都作罢 提交于 2019-12-02 05:50:33
前台代码起来越多,需要用一种更高效方式整合 MVC只是手段,终极目标是模块化和复用 第一部分:快速上手 1.1 感受AngularJS的4大核心特性 1.2 搭建开发、调试、测试环境 第二部分:基本概念和用法 2.1 MVC 2.2 模块化与依赖注入 2.3 双向数据绑定 2.4 指令 2.5 Service 2.6 Provider 2.7 表单 2.8 综合实例BookStore 第三部分:核心原理解析 3.1 Parser 3.2 双向数据绑定 3.3 依赖注入 第四部分:ng控件开发 4.1 用AngularJS改写jQuery控件 4.2 angularjs-ui 4.3 移动控件库ionic 第五部分:TDD前端自动化测试 5.1 TDD 5.2 详解Jasmine与Pracotor tool: http://www.oschina.net/p/angularjs-eclipse module: Jasmine resource: 官方教程 http://woxx.sinaapp.com/ 种子项目 https://github.com/angular/angular-seed 开源中国的 AngularJS 优秀文章汇总 http://www.oschina.net/news/54687/oschina-angular-articles-summary http:/

Load local JSON into Jasmine/Karma Unit Test in AngularJS

落爺英雄遲暮 提交于 2019-12-02 04:42:24
I'm testing a callback function which accepts a response object as it's only parameter. This object is the response of a HTTP request made elsewhere so I don't want to user $httpBackend in this test as the request has nothing to do with this function. It's in home.js which is a controller for the homepage of my app. Here is the function being tested: function submitLogin() { LoginService.login(loginPost, ctrl.username, ctrl.password, successCallback, errorCallback); } // gets called in LoginService if login reponse is 201, otherwise errorCallback called function successCallback(response) { //

unit testing typescript directive template karma-jasmine, html is not defined

自作多情 提交于 2019-12-02 04:33:38
问题 Recently i started unit testing on my typescript code using karma-jasmine. After creating and running test case for a service and a simple directive, i created one test case for custom directive which has one controller(which is injecting one service) and is using 4 scope variable for communicating with outside world. It's a simple unit test case to check whether directive is rendering its template or not. While running this unit test case, karma throws some error 09 03 2016 19:59:27.056:INFO

Protractor unable to find elements and script timeout

徘徊边缘 提交于 2019-12-02 04:28:42
问题 I'm running protractor, it runs successfully and load my angular app. The very first test I wrote is to get the sign-up button. Although I can see the sign-up button in my view and I'm targeting it with proper CSS. Still, all I get is this error after running the test. App ✗ should get the text of sign up button - Failed: script timeout: result was not received in 11 seconds (Session info: chrome=71.0.3578.98) (Driver info: chromedriver=2.45.615355 (d5698f682d8b2742017df6c81e0bd8e6a3063189)