jasmine

Isolation of actions and tests

牧云@^-^@ 提交于 2019-12-08 11:06:42
问题 I try to refactor my code. I know that if I have several expectations they should be isolate in 'it'. I try to understand how I can write instead this: describe('my scenario should make', function () { var config = browser.params; var url = config.listOfReferencesUrl, grid, numberField; it('test1', function () { browser.get(url); browser.executeScript("icms.go('WEB_INQ_PROC', 'InquiryList', null, 0)"); grid = psGrid(by.css("table[class='n-grid']")); numberField = grid.getQuickFilter(1);

testing angular service internal method calls

假装没事ソ 提交于 2019-12-08 10:10:39
问题 I have the following simple service app.factory('Shoes', function() { function a() {return 12;} function b() {return a();} return { a: a, b: b } }) I want to test if the method a is being called when I call method b . My test looks like this: describe('Testing a Shoes service', function() { var service; beforeEach(module('plunker')); beforeEach(inject(function(Shoes) { service = Shoes; })) it('.b should call .a', function() { spyOn(service, 'a'); service.b(); expect(service.a)

How to make parts of Protractor wait or become synchronous?

岁酱吖の 提交于 2019-12-08 08:52:28
I have code like this in a protractor test, it goes to a home page determines we need to login and then calls this function. Note I'm running this in a NODE.js environment: function Login() { browser.findElement(by.id('ID')).then(function (ele) { ele.sendKeys('SomeUserName'); browser.findElement(by.id('password')).then(function (ele) { ele.sendKeys('SomePassword'); browser.findElement(by.partialButtonText('Sign in')).then(function (ele) { ele.click(); browser.getCurrentUrl().then(function (url) { expect(url).toBe("http://NextURLAfterClick"); debugger; }); }); }); }); } But I can't get the

Running spec after promise has been resolved

久未见 提交于 2019-12-08 08:12:52
问题 I came across an issue with running a spec that should be executed after a promise has been resolved. See the commented simplified example below. I tried using IIFE or calling done() function in the spec but none of these seemed to work. // getIds() is a simple promise which returns an array of ids getIds().then(function (ids) { console.log('IDS: ' + ids); // all good so far // This test is never run it('dummy test', function () { console.log('TEST HAS BEEN RUN'); }); }); 回答1: You can use

How to define tests with Jasmine for $resource (AngularJS)

此生再无相见时 提交于 2019-12-08 07:50:35
问题 I want to define tests for my angular app but I don't know how to work with because it's my first time to write tests. However, it's important for me to define Tests with Jasmine for REST Service in my application. Well, my question is how can I test the GET requests. I was on the jasmine site and have read the sample there. But it was only a test whether the URL is correctly written. My intention is to check if I get response data back? Is that possible? Also in Angular Doc is written that

Protractor passes my tests without executing the 'it' blocks

笑着哭i 提交于 2019-12-08 06:54:38
问题 I've recently tried to use the Page Object Model with Protractor following this post http://engineering.wingify.com/posts/angularapp-e2e-testing-with-protractor/ However, when I run my tests, my it blocks do not get executed. Below is my login page object /*File Name : loginPage.js*/ var loginPage = function () { 'use strict'; this.email = element(by.id('Email')); this.next = element(by.id('next')); this.pwd = element(by.id('Passwd')); this.signin = element(by.id('signIn')); this.submitButton

TypeError: $scope is undefined in Angular controller unit test with Jasmine

一个人想着一个人 提交于 2019-12-08 06:53:10
问题 This is a very simple, quite pared down test and controller. My controller 'LedgerCtl' has an injected service 'LedgerService' that I test elsewhere, so in my LedgerControllerSpec I created a function that stands-in for the mocked service. When I execute the test, I get the 'scope undefined' error. this and this are the closest answers I found; however neither solve my issue. angular.module("TeamSportApp", []) .controller('LedgerCtl', function($scope, LedgerService) { $scope.ledger = []; //

How to make parts of Protractor wait or become synchronous?

我是研究僧i 提交于 2019-12-08 06:43:10
问题 I have code like this in a protractor test, it goes to a home page determines we need to login and then calls this function. Note I'm running this in a NODE.js environment: function Login() { browser.findElement(by.id('ID')).then(function (ele) { ele.sendKeys('SomeUserName'); browser.findElement(by.id('password')).then(function (ele) { ele.sendKeys('SomePassword'); browser.findElement(by.partialButtonText('Sign in')).then(function (ele) { ele.click(); browser.getCurrentUrl().then(function

Jasmine Test for ng-mouseenter

女生的网名这么多〃 提交于 2019-12-08 04:45:10
问题 I'm having trouble testing my directive with an ng-mouseenter directive. I'd like to test several things, but first off, I need to test that the method supplied to ng-mouseenter is called. my test: describe('hover tests', function () { it('the triggerPopover method should be called on hover', function() { spyOn($scope, 'triggerPopover'); var ars = jQuery(view.find('article.the-class-im-looking-for')); jQuery(ars[0]).trigger('mouseenter'); expect($scope.triggerPopover).toHaveBeenCalled(); });

Ionic 3 infinite-scroll simulate in e2e test jasmine/protractor

徘徊边缘 提交于 2019-12-08 04:39:13
问题 If you go here: http://ionicframework.com/docs/api/components/infinite-scroll/InfiniteScroll/ Inspect the demo and click the last item on the list: Then in the console type: $0.scrollIntoView() Infinite Scroll is never triggered. Is there a way to programmatically trigger infinite-scroll in protractor context? 回答1: The implementation of the scroll in your example rely on the speed/velocity of the scroll which I guess falls far from the expected range when scrollIntoView is called. One