Protractor e2e test case for downloading pdf file

I can currently set download path location Chrome capabilities: { ‘browserName’: ‘chrome’, ‘platform’: ‘ANY’, ‘version’: ‘ANY’, ‘chromeOptions’: { // Get rid of –ignore-certificate yellow warning args: [‘–no-sandbox’, ‘–test-type=browser’], // Set download path and avoid prompting for download even though // this is already the default on Chrome but for completeness prefs: { ‘download’: { ‘prompt_for_download’: … Read more

Output jasmine test results to the console

Have you tried the ConsoleReporter? jasmine.getEnv().addReporter(new jasmine.ConsoleReporter(console.log)); According to the code Jasmine has the ConsoleReporter class that executes a print function (in this case console.log) that should do what you need. If all else fails you could just use this as a starting point to implement your own console.log reporter. UPDATE In newer versions of … Read more

Expected a spy, but got Function

You need to get into the actual method, which in this case is on the prototype. describe(‘When onGivePoints is fired’, function () { beforeEach(function () { spyOn(UsersBoardCollection.prototype, ‘restartPolling’).andCallThrough(); app.vent.trigger(‘onGivePoints’); }); it(‘the board collection should be fetched’, function () { expect(UsersBoardCollection.prototype.restartPolling).toHaveBeenCalled(); }); }); Spying on the prototype is a nice trick you can use when you … Read more

AngularJS Promise Callback Not Trigged in JasmineJS Test

TL;DR Call $rootScope.$digest() from your test code and it’ll pass: it(‘should return false if user is not logged into Facebook’, function () { … var userLoggedIn; inject(function (Facebook, $rootScope) { Facebook.getUserLoginStatus($rootScope).then(function (data) { console.log(“Found data!”); userLoggedIn = data; }); $rootScope.$digest(); // <– This will resolve the promise created above expect(userLoggedIn).toEqual(false); }); }); Plunker here. Note: … Read more

Angular 2 fakeAsync waiting for timeout in a function using tick()?

The purpose of fakeAsync is to control time within your spec. tick will not wait for any time as it is a synchronous function used to simulate the passage of time. If you want to wait until the asynchronous function is complete, you are going to need to use async and whenStable, however, in your … Read more

angularjs route unit testing

Why not just assert the route object is configured correctly? it(‘should map routes to controllers’, function() { module(‘phonecat’); inject(function($route) { expect($route.routes[‘/phones’].controller).toBe(‘PhoneListCtrl’); expect($route.routes[‘/phones’].templateUrl). toEqual(‘partials/phone-list.html’); expect($route.routes[‘/phones/:phoneId’].templateUrl). toEqual(‘partials/phone-detail.html’); expect($route.routes[‘/phones/:phoneId’].controller). toEqual(‘PhoneDetailCtrl’); // otherwise redirect to expect($route.routes[null].redirectTo).toEqual(‘/phones’) }); });

How to unit test DOM manipulation (with jasmine)

I’ve been using a helpful addition to jasmine called jasmine-jquery available on github. It gives you access to a number of useful extra matcher functions, to assert jquery objects and their properties. In particular the features I have found useful so far are asserting on attributes of dom elements, and spying on events such as … Read more

Mock a service in order to test a controller

What I was doing wrong is not injecting the Mocked Service into the controller in the beforeEach: describe(‘Controller: AddBookCtrl’, function() { var scope; var ParseServiceMock; var AddBookCtrl; // load the controller’s module beforeEach(module(‘BookCrossingApp’)); // define the mock Parse service beforeEach(function() { ParseServiceMock = { registerBook: function(book) {}, getBookRegistrationId: function() {} }; }); // inject the … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)