1
vote
0answers
19 views

Angular JS/Karma Unit Testing with Angular UI-Router

I'm working on an Angular app that uses Angular UI-Router for routing and maintaining state. I am having a hard time getting my unit test to even compile. It seems that no matter what I do, I keep ...
0
votes
1answer
6 views

timezoneJS will not resolve time zones in unit test

I'm unit testing an AngularJS application using Jasmine and Karma. The unit test I'm currently working on is a date service that will parse strings into dates and return a timezoneJS object. I've ...
0
votes
1answer
6 views

angularjs factory wrapper around lodash not loaded in test

So I have the following: angular.module('common.lodash', []).factory('_', function() { _.additionFunctionOnLodashThatICreated = function(foo, bar, baz) { ... }; return _; }); I depend upon ...
0
votes
1answer
23 views

Best practices for unit testing angular directives

I'm writing some unit tests for directives in AngularJS using Jasmine and Karma as my test runner. As I'm doing this, I'm wondering whether or not I'm following the best means of setting this up and ...
0
votes
0answers
11 views

How can I simulate blur when testing directives in angularjs?

I am trying to test some directives. First off I have an email (called epost in the code(norwegian)) directive. The directive validates email addresses in two ways; on upshift and on blur. I can test ...
0
votes
1answer
17 views

How do I stub a response for an Angular $resource that depends on an external service?

How do I stub a response instead of querying $resource that depends on an external service? I'm getting an error: Error: Unexpected request: GET data/counties.json Here's my service: ...
0
votes
0answers
14 views

Unit testing a directive that defines a controller in AngularJS

I'm trying to test a directive using Karma and Jasmine that does a couple of things. First being that it uses a templateUrl and second that it defines a controller. This may not be the correct ...
0
votes
0answers
15 views

$httpBackend cannot flush() in the demo

http://docs.angularjs.org/tutorial/step_05 I keep getting errors from executing the karma.conf.js, with the error No Pending Request to Flush!!! From What I understand the $httpBackend is the way ...
0
votes
1answer
20 views

Testing angular services with controllers

I have my custom angular service, which has one method that handles with $scope.$watch, is it possible to unit test it? angular.module('moduleName', []).factory('$name', function () { return { ...
1
vote
1answer
29 views

Throw error in error function of $http causes $digest already in progress in unit test

Here is a plunker showing the issue: http://plnkr.co/edit/J8zRIj?p=preview Here is a plunker with the error commented out in both the scripts.js and scripts.spec.js and I don't get the $digest error ...
1
vote
0answers
18 views

AngularJS: how to invoke event handlers and detect bindings in tests

I want to write unit and e2e tests for various custom angularjs directives that add javascript event bindings to the elements they are attached to. In tests, it's easy enough to simulate click and ...
0
votes
1answer
28 views

Angularjs testing (Jasmine) - $http returning 'No pending request to flush'

My UserManager service automatically fires a $http POST every hour to refresh the user access token. I'm trying to mock that call to verify that the token is being refreshed, but when I try to flush ...
0
votes
1answer
42 views

Mocking Angular module dependencies in Jasmine unit tests

I'm attempting to unit test controller code inside a module that takes other modules as dependencies, but haven't been able to figure out how to mock them properly. I'm using the Jasmine Framework ...
1
vote
0answers
16 views

Using $timeout-Mock in AngularJS with delay

I've used $timeout with a delay of e.g. 600ms in some service code. In the according test I want to assert that the code really does what it is expected to do after the given 600 ms. Is there any way ...
0
votes
0answers
24 views
+50

How do you mock directives to enable unit testing of higher level directive?

In our app we have several layers of nested directives. I'm trying to write some unit tests for the top level directives. I've mocked in stuff that the directive itself needs, but now I'm running into ...
0
votes
1answer
50 views

Angularjs mocking service with wraped $http.post

I am trying to test a service with other services Dependencies. One service has a method like so var getBasicInformation = function(token){ return $http.post(basicInformationUrl, {token: token}); ...
3
votes
2answers
147 views

How to Unit Test Isolated Scope Directive in AngularJS

What is a good way to unit test isolated scope in AngularJS JSFiddle showing unit test Directive snippet scope: {name: '=myGreet'}, link: function (scope, element, attrs) { //show ...
0
votes
1answer
67 views

How to write unit test for AngularJS model

I've got a basic model that I am trying to write a simple unit test suite for, and I'm clearly missing something... The code for the model looks like this: angular.module('AboutModel', []) ...
0
votes
1answer
26 views

Configuring Angular service provider in Jasmine test

I have a service on my someModule module: someModule.provider('someService', function() { this.options = {}; this.$get = function () { return options; }; }); I am writing a ...
0
votes
1answer
19 views

How to test an AngularJS provider configuration?

I have a provider defined as follows: (function(angular) { angular.module('myModule', []) .provider('myService', function () { var service = {}; service.configureSomething = function () { }; ...
2
votes
1answer
139 views

AngularJS Test Controller Containing routeChangeSuccess

I am trying to create unit tests to test a navigation list controller, and I'm having issues with creating the tests. Here is the code for the controller. navListModule.controller('NavListCtrl', ...
0
votes
1answer
71 views

Angular scope in jasmine controller tests

Trying to understand how do jasmine tests work. I've got a module and a controller: var app = angular.module('planApp', []); app.controller('PlanCtrl', function($scope, plansStorage){ var plans = ...
1
vote
1answer
44 views

Code Coverage of Routes is 100% without Any Test

I'm writing tests for a simple AngularJS project, and using Istanbul to work out code coverage. I've got a file that has 100% code coverage according to istanbul, but I don't have any test for it: ...
0
votes
1answer
97 views

How to use mock $httpBackend to test error branch

I am following the AngularJS documentation from here The problem is that the documentation describes only the "success/happy" branch of the code, and there is no example of how to test the "failure" ...
0
votes
1answer
79 views

Testing a AngularJS services with dependencies

I have som issues testing a simple service in AngularJS, which depends on another service. The service looks a bit like this: serviceModule.factory('filtersService', ['$rootScope', 'urlService', ...
1
vote
0answers
37 views

Angularjs how can I unit test a Service which depends on another Service with promises?

How can I test a service which depends on another service. I currently get Service1Provider not found error in this implementation. How can I properly inject Service1 so I can unit test Service2? ...
0
votes
0answers
32 views

JS testing framework - in between acceptance and unit testing

I've searched for a while about JS testing frameworks and came across this post. The mentioned testing frameworks are: QUnit, Jasmine, Karma, JSTestDriver, YUI, TestSwarm, and JSUnit as well as Mocha. ...
1
vote
0answers
47 views

Mocking dates in AngularJS / Jasmine tests

I have a directive that initializes the Date object several times in several functions. When Unit testing the individual functions I can handle stubbing the date like this: (function (global) { ...
1
vote
0answers
61 views

Unit test file setup for Angular JS

I am writing my first unit tests for an Angular JS project, and I'm wondering how to lay thing out in a easy to understand and maintain manner. For directives for example the examples I have found so ...
2
votes
1answer
165 views

Unit testing in AngularJS with mock $resource

Trying to get my some units tests in AngularJS (using jasmine & karma) working and struggling to comprehend dependency injection... current error message in karma reads 'Error: Argument 'fn' is ...
0
votes
0answers
35 views

How to fix “TypeError: httpBackend.when is not a function in …https://waybackassets.bk21.net/test/unit/unittest.js”?

I am having a problem setting up a mock httpBackend. I have looked through the API multiple times and I have setup my code following the same procedure. The unit test that I am trying to run is below: ...
1
vote
0answers
121 views

Unit testing angular ng-resource

Hi i'm currently setting up some unit test with karma and jasmine. And i'm having difficulties trying to fully test an ng-resource. When i do an scope.clients.query() is executes a request. But when i ...
1
vote
1answer
229 views

Testing AngularJS controllers with resource services

Background: I'm writing unit test for angular js controllers, which utilize angular $resources wrapped in services (for maintainability purposes). Example controller: name = ...
2
votes
1answer
147 views

Effectively unit test an AngularJS directive which is manipulating the DOM

I am working on a simple directive with AngularJS to add a smooth scrolling effect to any link. I have published my work here: https://github.com/arnaudbreton/angular-smoothscroll Everything works in ...
0
votes
1answer
56 views

How can I solve Error during testing Angular Js in netbeans?

After following this example https://netbeans.org/kb/docs/webclient/html5-js-support.html I always get that error: Exception in thread "main" java.lang.NoClassDefFoundError: ...
0
votes
0answers
55 views

Karma unaware of .constant provider defined in script tag

I need to define a csrf constant inside a script tag on a html page rendered by the server-side templating engine. Something like <script type="text/javascript" src="app.js"> <script ...
0
votes
1answer
107 views

AngularJS mocking $logProvider in config block

Is there a way to inject providers when writing unit tests using Karma(Testacular) and Jasmine in angular? Our team decided recently to use angularjs $log to write debugging details to the console. ...
-1
votes
1answer
65 views

AngularJs Unit Test

I am new in angular JS I want test angular-seed sample, e2e test run ok, but i can not test unit test (directive, ...), i get this sample from github, and not change this, but have this problem i get ...
2
votes
0answers
50 views

Unit test directive inside a directive

I'm having troubles unit testing a directive that wraps the ng-grid component. I've written this punkler that shows the issue : http://plnkr.co/edit/HlB8Bt9M2TzsyM6XaDso?p=preview There is a lot of ...
0
votes
2answers
131 views

How can I test Broadcast event in AngularJS

I have a controller which emits a broadcast event on the rootscope. I would like to test that the broacast event is fired correctly. My code in my controller looks like this: ...
0
votes
1answer
897 views

Jasmine unit tests: $compile produces comment out of ng-repeat

Why the line var scope = $rootScope.$new(); dump($compile('<ul><li ng-repeat="item in [1,3,5,7,9]">{{item}}</li></ul>')(scope)); results in: '<ul ...
0
votes
1answer
137 views

Karma + Sinon fake timer = global leak errors?

I'm trying to use Sinon's fake timers in some of my unit tests (Karma runner with Mocha). As soon as I add clock = sinon.useFakeTimers(); to my setup() function, I get the following error: Chrome ...
0
votes
0answers
159 views

Angularjs $http mock issues

I need a little help formatting my unit test to get the expected results from testacular/karma beforeEach( inject( function( customService, $httpBackend ){ service = ...
0
votes
1answer
193 views

How to unit test Angular controller with $scope.$on?

I have a controller with an event listener in my Angular app, defined as follows. angular.module('test').controller('TestCtrl', function($rootScope, $scope, testService) { [...] ...
1
vote
1answer
998 views

Testing modular AngularJS w/ Jasmine & Karma

Struggling to get unit testing set up in Jasmine/Karma. I have a controller with a service dependency, and that service has another service dependency. I am not organizing my modules by type ...
1
vote
1answer
534 views

Angular.js code coverage using Karma w. Coffeescript

I had some difficulties running Istanbul code coverage tool with Angular.js + Jasmine. I'm coding in Coffeescript, but since Instanbul doesn't support it yet, source is converted to JS on every save. ...
1
vote
0answers
275 views

AngularJS + Karma: reuse a mock service when unit testing directives or controllers

I'm working with AngularJS + Karma. configService manages the settings of my app (e.g. the background-color, wether it's on debug mode, general permissions...). It loads initial data with $http. I ...
0
votes
1answer
284 views

How do I get a resource from an Angular.js module for a jasmine test

I have a module that contains resources for a project, and the code looks like this: editor_services.js var editorServices = angular.module('editorServices', ['ngResource']); ...
1
vote
1answer
614 views

Unit testing AngularJS controller with $httpBackend

For the life of me I can't get $httpBackend to work on a controller that does an $http get request. I've tried for hours now =) I've reduced this to the simplest form I can below. The test passes ...
0
votes
2answers
96 views

AngularJS: test that an external script is effectively loaded

I'm working with an external script (from http://segment.io) and I'm writting an AngularJS module to interact with it. I am wondering how can I effectively test that their script is well loaded ...

1 2 3
15 30 50 per page