Search Posts

Category: chai

Serenity Protractor Click function is not working as expected

Description: I’m doing an automation for a time schedule which has 2 schedule states OPEN, CLOSE and when I select CLOSE it gives a pop-up to submit a reason to CLOSE it and in that pop-up there is a submit button that I have to click to complete the task. And when I press the submit button I’m passing the Status which is “CLOSE” to the onClick method in UI to the method as an […]

How to update $scope using Sinon test with $interval.flush and clock.tick

So, I have a plunker setup with the sample code in question: http://plnkr.co/edit/HvMbtr6w3NtxZpsJY4BI?p=preview My problem, is that I have a function in home.controller.js PopularMovies.query(function(data) { results = data; findMovie(results[0]); console.log(“$interval Start”, Date.now()); $interval(function() { ++idx; console.log(“$interval idx[” + idx + “]”, Date.now()); console.log(“results[idx % results.length]”, results[idx % results.length]); findMovie(results[idx % results.length]); }, 5000); }); When triggered, expect it to call `findMovie()` every 5000ms. To test this, I have a test written in the home.controller.spec.js file: […]

Why does a failed assertion trigger a promise catch?

While writing unit tests for an angular app I was experiencing unexpected results. I was able to condense the unexpected behavior into a sample test. The should.equal(true, false, ‘should then’) assertion failure in the then block seems to trigger the catch block of the promise. describe.only(‘test’, function () { var $q, $rootScope; beforeEach(function () { inject(function(_$q_, _$rootScope_) { $q = _$q_; $rootScope = _$rootScope_.$new(); }); }); var stubService = sinon.stub(service, ‘getPanel’); it(‘shall…’, function() { //1 […]