jasmine

How do I test an externally served app using Testacular + AngularJS

房东的猫 提交于 2019-12-03 21:33:13
I have an app running on http://localhost:6543 - it's a Pyramid app. This app serves the AngularJS app at / This app uses socket.io itself The question is: is it possible to test that application using those tools ? I have this in my scenario.js file: beforeEach(function() { browser().navigateTo('http://localhost:6543/'); }); but the moment I launch testacular (with run or start ), I get this error message: Chrome 23.0 registration: should delete all cookies when user clicks on "remove all" button FAILED browser navigate to 'http://localhost:6543/' /home/abourget/myapp/jstests/scenarios

protractor-html-screenshot-reporter not showing any report after test execution

对着背影说爱祢 提交于 2019-12-03 20:40:26
I am using protractor to automate a hybrid mobile app, I am using the Protractor-HTML-screenshot-reporter, but it is not displaying any report after successful test execution. Here's my code below: var HtmlReporter = require('protractor-html-screenshot-reporter'); var reporter=new HtmlReporter({ baseDirectory: 'C:\\Users\\bhawani.prasad\\Desktop\\Protractor\\PageObject\\report', // a location to store screen shots. docTitle: 'Protractor Demo Reporter', docName: 'protractor-demo-tests-report.html' }); onPrepare: function() { jasmine.getEnv().addReporter(reporter); } , For those who are

AngularJS + Protractor sum all row values in repeater

孤街醉人 提交于 2019-12-03 20:32:25
I'm testing AngularJS with Protractor, I have a repeater and I'm trying to sum all values in the rows, and compare it to the summary line value. Here's my HTML: <table> <th> <td>100</td> </th> <tr data-ng-repeat="item in publishers_data"> <td>{{item.a}}</td> </tr> </table> I used the following code in my e2e test: var total = 100; var sum = 0; element.all(by.repeater("item in publishers_data")).then( function(rows){ for(var i=0;i<rows.length;i++){ sum + = rows(by.model("{{item.a}}").getText(); } }); expect(sum).toEqual(total); I'm getting various kind of errors, can someone advice what am I

Angular Protractor e2e Testing

允我心安 提交于 2019-12-03 19:54:02
问题 I am writing an end-to-end test using Protractor for my Angular application. I can mock httpBackend for unit test but I want to actually call the server and get the JSON response back and write tests again the data returned. I have read a lot on stackoverflow but can not understand how this is done. Do I use $http? How do I inject it into my Jasmine tests? How do I get the response JSON back into my Jasmine test? any help or links to resources with instructions on doing this will be helpful.

How to unit test a chained method using Jasmine

爷,独闯天下 提交于 2019-12-03 19:30:52
问题 I'm having a problem unit testing the following method: $scope.changeLocation = function (url) { $location.path(url).search({ ref: "outline" }); }; I've written the following unit test that currently fails with this error (TypeError: Cannot read property 'search' of undefined): var $locationMock = { path: function () { }, search: function () { } }; it('changeLocation should update location correctly', function () { $controllerConstructor('CourseOutlineCtrl', { $scope: $scope, $location:

How to use jasmine to test an async function that takes a long time to respond?

我与影子孤独终老i 提交于 2019-12-03 17:52:36
问题 I'm using a function to fetch data from webapi. Basicly using $.ajax . I'm now testing it with waits() like this: describe('xxxxxxxxxxxxxxxxxxxxx', function () { var r; it('fetchFilter', function () { runs(function () { model.fetch(opts) .done(function(data) { r = data; }); }); waits(2000); runs(function () { expect(r[0].gender).toBeDefined(); }); }); }); The problem is: It's not guaranteed that waits(2000) will do the job well. Due to various reasons(network connections, algorithm efficiency

Configuring Angular service provider in Jasmine test

我只是一个虾纸丫 提交于 2019-12-03 17:44:02
问题 I have a service on my someModule module: someModule.provider('someService', function() { this.options = {}; this.$get = function () { return options; }; }); I am writing a spec, and so far I have the following: beforeEach(mocks.module('directives', ['someModule'])); beforeEach(function () { directives.config(function (someServiceProvider) { someServiceProvider.options({ foo: 'bar' }); }); }); I need to configure my someService service before each test in my spec. However, the following code

Jasmine angularjs - spying on a method that is called when controller is initialized

拈花ヽ惹草 提交于 2019-12-03 17:35:50
I am currently using Jasmine with Karma(Testacular) and Web Storm to write unit test. I am having trouble spying on a method that gets called immediately when the controller is initialized. Is it possible to spy on a method that is called when the controller is initialized? My controller code, the method I am attempting to spy on is getServicesNodeList() . myApp.controller('TreeViewController', function ($scope, $rootScope ,$document, DataServices) { $scope.treeCollection = DataServices.getServicesNodeList(); $rootScope.viewportHeight = ($document.height() - 100) + 'px'; }); And here is the

Check POST request payload data with Protractor

扶醉桌前 提交于 2019-12-03 16:59:15
Let's say i have angular page with a couple of input elements and save button. After Save button is clicked POST request will be sent. I'm writing Protractor e2e test for this page. The question: How can i check with protractor POST request payload data after app is sent it or before sending? I want to be sure that my app will sent right data in POST request. Following @Andres D's comment: yes, there is a misconception here. protractor is a tool that helps you mimic real-user interactions with a page by automating a real browser. It stays on the high-level, sees what a normal user can see -

Protractor - ScriptTimeoutError: asynchronous script timeout: result was not received in 20 seconds

丶灬走出姿态 提交于 2019-12-03 16:52:22
问题 I'm new to Protractor and I am trying to run my script. describe('Navigator homepage', function() { it('should proceed to login', function() { browser.get('url'); }) it('Clicks the proceed button',function() { const proceedButton = element(by.id('auth-login-page-button')); proceedButton.click(); }); }); But whenever I run it the browser opens up and proceeds to the website and then waits for 20 sec and I get Error: ScriptTimeoutError: asynchronous script timeout: result was not received in 20