jasmine2.0

Jasmine testing .load() to get called URL

淺唱寂寞╮ 提交于 2019-12-12 23:02:35
问题 I have a function which loads a template and I want to check the correct URL is being called. As I can't find any information other than for spying on ajax calls, I'm presuming it's the same for .load() calls. I'm using Jasmine 2.4.1 Function function templateLoader() { var templateURL = '/path/to/template.html'; $('#myElement').load(templateURL, function(response, status, xhr) { if (status === "error") { common.templateError(templateURL, xhr); } else { ns.successFunction(); } }); } Jasmine

Jasmine Async Testing

删除回忆录丶 提交于 2019-12-11 07:49:26
问题 I'm attempting to test a value that is set asynchronously using Jasmine 2's new done() callback. I've based my test after the example Jasmine gives in their documentation (http://jasmine.github.io/2.0/upgrading.html#section-Asynchronous_Specs): it('can set a flag after a delay', function(done) { var flag = false, setFlag = function() { //set the flag after a delay setTimeout(function() { flag = true; done(); }, 100); }; setFlag(); expect(flag).toBe(true); }); I'm getting the result "Expected

Protractor failed to start test with firefox

佐手、 提交于 2019-12-08 06:56:29
I can not start the test with protractor on firefox version 56.0.1. my protractor version is 5.1.2 exports.config = { allScriptsTimeout: 11000, specs: [ './e2e/**/*.e2e-spec.ts' ], capabilities: { 'browserName': 'firefox' }, directConnect: true, baseUrl: 'http://localhost:4444/', framework: 'jasmine', jasmineNodeOpts: { showColors: true, defaultTimeoutInterval: 30000, print: function() {} }, }; this is the error: [00:02:20] I/launcher - Running 1 instances of WebDriver [00:02:20] I/direct - Using FirefoxDriver directly... [00:02:27] E/launcher - Unable to parse new session response: {"value":

Explain about async/ await in Protractor

帅比萌擦擦* 提交于 2019-12-03 07:30:47
问题 I'm new to protractor. How does async/await in this function works? Can anybody explain it to me? it('TC_01 - Verify Home page title', async () => { await headerPage.waitForTitleContain('Homepage', 30000); await expect(headerPage.getTitle()).toEqual('Homepage'); }); 回答1: This is all about asynchronous nature of JavaScript. Currently protractor proposes several ways to handle asynchronous actions, (I didn't describe direct promise chaining, and generators here): 1) Promise Manager/ Control

Protractor flakiness

巧了我就是萌 提交于 2019-12-03 06:02:51
问题 I maintain a complex Angular (1.5.x) application that is being E2E tested using Protractor (2.5.x). I am experiencing a problem with this approach, which presents primarily in the way the tests seem flaky. Tests that worked perfectly well in one pull request fail in another. This concerns simple locators, such as by.linkTest(...). I debugged the failing tests and the app is on the correct page, the links are present and accessible. Has anyone else experienced these consistency problems? Knows

Protractor flakiness

邮差的信 提交于 2019-12-02 22:19:56
I maintain a complex Angular (1.5.x) application that is being E2E tested using Protractor (2.5.x). I am experiencing a problem with this approach, which presents primarily in the way the tests seem flaky. Tests that worked perfectly well in one pull request fail in another. This concerns simple locators, such as by.linkTest(...). I debugged the failing tests and the app is on the correct page, the links are present and accessible. Has anyone else experienced these consistency problems? Knows of a cause or workaround? alecxe Just Say No to More End-to-End Tests! That said, here are the few

Getting “$digest already in progress” in async test with Jasmine 2.0

两盒软妹~` 提交于 2019-12-02 21:47:39
I know that calling $digest or $apply manually during a digest cycle will cause a "$digest already in progress" error but I have no idea why I am getting it here. This is a unit test for a service that wraps $http , the service is simple enough, it just prevents making duplicate calls to the server while ensuring that code that attempts to do the calls still gets the data it expected. angular.module('services') .factory('httpService', ['$http', function($http) { var pendingCalls = {}; var createKey = function(url, data, method) { return method + url + JSON.stringify(data); }; var send =

Explain about async/ await in Protractor

痴心易碎 提交于 2019-12-02 21:04:18
I'm new to protractor. How does async/await in this function works? Can anybody explain it to me? it('TC_01 - Verify Home page title', async () => { await headerPage.waitForTitleContain('Homepage', 30000); await expect(headerPage.getTitle()).toEqual('Homepage'); }); Xotabu4 This is all about asynchronous nature of JavaScript. Currently protractor proposes several ways to handle asynchronous actions, (I didn't describe direct promise chaining, and generators here): 1) Promise Manager/ Control Flow https://github.com/SeleniumHQ/selenium/wiki/WebDriverJs#control-flows This is abstraction that

Spec has no expectations - Jasmine testing the callback function

核能气质少年 提交于 2019-12-01 14:00:45
问题 I have a method which is being called using a d3 timer . Whenever the method is called, the method emits an object with a couple of values. One of the values increases over time. I would like to write a test to check whether the values are in the ascending order or not (i.e., increasing over time or not). So, to tackle this, In my test, I subscribe to the event emitter and inside the subscription, I am pushing the object which I receive into a local array. And then, I am expecting the array[i

how to test and resolve Controller data (.then function()) promise and get orginal Data in Jasmine2

泪湿孤枕 提交于 2019-11-28 02:25:23
I am testing a controller that uses a service that returns a promise. I need to resolve promise. I am using Jasmine 2. Here is Spec code beforeEach(inject(function ($controller, $rootScope, _myService_, _$q_, _$rootScope_, _$httpBackend_, $http) { scope = $rootScope.$new(); $q = _$q_; $httpBackend = _$httpBackend_; $rootScope = _$rootScope_; myService = _myService_; $http = $http; ctrl = $controller('Ctrl', { '$scope': scope, 'myService': myService }); spyOn(myService, "getDateRangeData").and.callThrough(); })); it('getDateRangeData return Data obj', function() { myService.getDateRangeData()