jasmine

Couldn't run protractor scripts on Android emulator

隐身守侯 提交于 2019-12-04 20:09:59
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 webdriver instance. capabilities: { 'browserName': 'chrome', 'device': 'android', 'deviceName' : '5554

How can I set the viewport size of PhantomJS through grunt & jasmine?

心不动则不痛 提交于 2019-12-04 20:03:14
I'm trying to test something using grunt + jasmine + phantomjs. This specific test requires a large viewport so the responsive styles render the large-screen version within phantomjs. I noticed in the grunt-contrib-jasmine plugin this code, which would seem to allow for setting phantomjs options: // Merge task-specific options with these defaults. var options = this.options({ ... phantomjs : {}, ... }); However, when I add this to my config in grunt it has no effect: options: { phantomjs: { viewportSize: { width: 2000, height: 1000 } } } The answer lies in the fact that viewportSize is an

Testing controller with injected service inside angularJS with jasmine

谁说胖子不能爱 提交于 2019-12-04 20:00:52
问题 I am trying to understand how to test my code with jasmine and angularJS. I wrote a test project with a controller and an injected service. Now i want to test the controller and tried to mock the injected service. But i didn’t found a way to test the function “Arrived” from my controller. Here’s my jsfiddle: http://jsfiddle.net/2fwxS/ controller.js: angular.module('myApp.controllers', []) .controller('MyCtrl', ['$scope', 'MyService', function ($scope, MyService) { $scope.User = {}; $scope

Jasmine/Protractor: stop test on failure in beforeEach

淺唱寂寞╮ 提交于 2019-12-04 19:31:22
问题 I am currently writing tests protractor and I was wondering if there is some possibility to cancel test execution as soon as something in the beforeEach fails (and return some useful message like "precondition failed: could not login user"). I.e. I have some helper methods in the beforeEach that login the user and then do some setup. beforeEach: 1) login user 2) set some user properties Obviously it does not make any sense to execute the 2nd step if the first one fails (actually its quite

Branches on constructor not covered

一笑奈何 提交于 2019-12-04 19:13:08
问题 I am creating my unit tests with Jasmine and I have a question about the branch covered. Does anyone know why the code part shows that the branches are not covered as we can see below? This is the unit test: describe('MyComponent', () => { let component: MyComponent; let fixture: ComponentFixture<MyComponent>; let myService: MyService; beforeEach(async(() => { TestBed.configureTestingModule({ declarations: [ MyComponent ], imports: [ MaterializeModule, FormsModule, ReactiveFormsModule,

Error: Please call “TestBed.compileComponents” before your test

时间秒杀一切 提交于 2019-12-04 19:12:05
问题 I'm getting this error: Error: This test module uses the component MessagesComponent which is using a "templateUrl", but they were never compiled. Please call "TestBed.compileComponents" before your test. When trying to run this simple test Angular 2 & Jasmine Test: let comp: MessagesComponent; let fixture: ComponentFixture<MessagesComponent>; describe('MessagesComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ declarations: [ MessagesComponent ], providers: [ {provide:

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

醉酒当歌 提交于 2019-12-04 18:23:16
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 right way with element(by.css('button[ng-disabled=clicked]')).click(); ? You can find here the html

Test login with protractor on a non angular page

∥☆過路亽.° 提交于 2019-12-04 18:13:13
问题 I am trying to use protractor for e2e testing but first I need to login on a non-angular page. I try to directly use the webDriver as indicated here but it fails. My e2e test: describe('angularjs homepage', function() { it('should prompt the login page', function() { browser.get('/'); expect(browser.driver.find(By.id('user_password'))); }); }); My logs: Running "protractor:all" (protractor) task Using the selenium server at http://localhost:4444/wd/hub F Failures: 1) angularjs homepage should

Testing a Controller using Jasmine in Karma

╄→尐↘猪︶ㄣ 提交于 2019-12-04 17:55:57
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', function () { it('should call test variable', function () { $scope = $rootScope.$new(); ctrl = $controller(

Angular 2 tests - get DOM element styles

依然范特西╮ 提交于 2019-12-04 17:38:25
问题 I want to test the functionality of my hide-show button in my Angular 2 app(Tests are written in Jasmine), so I need to check the value of the display property of the relevant element. How can I get this property using Angular's debugElement ? Test code: let input = fixture.debugElement.query(By.css('input')); expect(input.styles['visibility']).toBe('false'); I get the error: Expected undefined to be 'false'. 回答1: I was having the same issue. The DebugElement.styles is always an empty object