jasmine

Couldn't run protractor scripts on Android emulator

≯℡__Kan透↙ 提交于 2019-12-06 13:07:51
问题 I want to execute protractor script on android emulator using Appium, but the problem emulator isn't launched when i tap: " protractor conf.js " on terminal. The test is passed in chrome browser of windows instead of browser in the emulator. Shall i add other capabilities ? or i should change the base url ? // An example configuration file. exports.config = { seleniumAddress: 'http://localhost:4733/wd/hub', specs: ['todo-spec.js'], directConnect: true, // Capabilities to be passed to the

Cannot inject service into its Angular unit test

你。 提交于 2019-12-06 12:33:04
I'm trying to unit test an Angular service using: angular 1.3.8 angular-mocks 1.3.8 karma 0.13.19 jasmine 2.4.1 node 0.10.33 OS: Windows 7 Browser: PhantomJS 2.1.3 The problem is, the service I wish to test ( MyService ) is not injected in the test file by the angular-mocks lib (i.e. the 'inject' method does nothing). My code looks as follows: main.js (function() { 'use strict'; angular.module('module', [ 'ngCookies', 'ngSanitize' ]); })(); service.js (function () { 'use strict'; angular.module('module') .factory('MyService', MyService); MyService.$inject = ['Dependency']; function MyService

How can i identify element by model or by name in this the following example?

旧城冷巷雨未停 提交于 2019-12-06 12:25:10
问题 I 'm using protractor to automate my tests, in order to click into the login button the action couldn't be executed when i tried to identify element by name, xpath, id ... element(by.name('Login')).click(); It works only when i identify it by css : element(by.css('.login-button')).click(); or element(by.css('button[ng-disabled=clicked]')).click(); But the problem the test is passed and user isn't redirected to home page even if i put browser.sleep(8000); Is the login button identified by the

angular-ui/bootstrap: Testing a controller that uses a dialog

跟風遠走 提交于 2019-12-06 12:15:52
I've a controller that uses a Dialog from angular-ui/bootstrap: function ClientFeatureController($dialog, $scope, ClientFeature, Country, FeatureService) { //Get list of client features for selected client (that is set in ClientController) $scope.clientFeatures = ClientFeature.query({clientId: $scope.selected.client.id}, function () { console.log('getting clientfeatures for clientid: ' + $scope.selected.client.id); console.log($scope.clientFeatures); }); //Selected ClientFeature $scope.selectedClientFeature = {}; /** * Edit selected clientFeature. * @param clientFeature */ $scope

Making an API call while running protractor tests

穿精又带淫゛_ 提交于 2019-12-06 11:30:50
问题 I have built a web application using angular2.0 and typescript . Now I am writing E2E for my site using protractor . Now, in one of my tests I need to make an API call(HTTP GET request) and use the response value as an input in my test case. So basically I want to know how to make a GET request in Protractor-Jasmine and use the result/response. 回答1: Protractor runs on top of nodejs, and under the hood is calling Selenium API. You can use all of the node libraries, including request . Choose

Testing a Controller using Jasmine in Karma

时光毁灭记忆、已成空白 提交于 2019-12-06 11:10:43
问题 I'm trying to test a controller but I'm getting an error TypeError: Object # has no method 'apply' ReferenceError: inject is not defined The unit-test.js is define(['angular', 'myApp', 'angularMocks', 'MyCtrl' ], function() { describe('Testing controller', function() { var $scope = null; var ctrl = null; beforeEach(angular.module('myApp')); beforeEach(inject(function ($injector) { $scope = $injector.get('$rootScope'); $controller = $injector.get('$controller'); })); describe('MyCtrl',

Unit test 'success' and 'error' observable response in component for Angular 2

核能气质少年 提交于 2019-12-06 10:46:48
I'm writing a unit test for a component that makes a call to a service OnInit. If the response is a 'success' one action taken and another for an 'error'. What is the best way to test both cases? I've created a simplified version of the component and unit test. Something that I could easily test against in both cases. I've attempted to implement the solution here but I must be off on the implementation. I've also attempted to throw an error as you will see in the spec and comments. Component @Component({ selector: 'app-observer-throw-unit-test', template: '<p>{{ data }}</p>' }) export class

Jasmine clock tick & Firefox: failing to trigger a Q.delay method

爱⌒轻易说出口 提交于 2019-12-06 10:24:44
Lazy loading tests: I am trying to build a test for Jasmine to test a method that uses Q.delay . To go around the 10 seconds wait i'm using Jasmine's clock : jasmine.Clock.tick(10010); This works on Chrome but does not work on Firefox. I saw that the delay method of Q utilized setTimeout so I can't see any reason for the different behaviors. Any ideas why it fails on Firefox? With jasmine 2.0 and Q at the v1 tag , I'm able to run this spec: describe("testing", function() { beforeEach(function() { jasmine.clock().install(); }); afterEach(function() { jasmine.clock().uninstall(); }); it("should

Unit Test Expect SpyOn Not Found

五迷三道 提交于 2019-12-06 09:57:55
I have a directive (restrict A) that handles an event click, and calls a service based on a value. Directive: define(function () { 'use strict'; var myDirective = function ($rootScope, myFactory) { return { restrict: 'A', scope: { _myValue : '=value' }, link: function(scope, element, attrs) { element.bind('click', function() { if (scope._myValue === 'red') { myFactory.red(); } if (scope._myValue === 'green') { myFactory.green(); } if (scope._myValue === 'black') { myFactory.black(); } }); } }; }; return ['$rootScope', 'myFactory', myDirective]; }); Test: define(['angular-mocks'], function () {

How to test John papa vm.model controllers and factories unit testing with jasmine?

你。 提交于 2019-12-06 09:40:30
Ive been using John Papa's style guide for my angular apps and Im just starting to get into the testing. However I can't seem to find any good documentation regarding testing the style with mocha, chai, and jasmine. Here is an example of one of my controllers (function () { 'use strict'; angular.module('app').controller('appController', appControllerFunction); function appControllerFunction($scope, $rootScope, $location, dataService, dataFactory) { var vm = this; function getData() { vm.data = dataService.returnData().then(function(data){ ... //http service returning data }); ... } getData();