Can't setup Karma and Jasmine for Angularjs

I've tried several tutorials and looked at many of the solutions provided here. I am new to Angular and currently trying to set up testing for a rather big SPA. Following this tutorial I have completed: Angularjs application setup Karma setup Ou...
more »

2017-09-22 08:09 (3) Answers

Unit Test Resolve Block in agnular component

Does anyone know how to unit test resolve block items in a routed component? It would be great if anyone can test courseDetails in the resolve block as an example. (function() { 'use strict'; angular .module('writingsolutionsCompone...
more »

2017-07-16 17:07 (1) Answers

karma unable to find test files

I am using karma, browserify and babelify to run unit tests for angular 2. Whenever I run it it fails with a 404 error like this 25 05 2017 11:35:22.974:WARN [web-server]: 404: /C://Users//me//git//proj-ng//modules//pack\\src//test.service.spec.js ...
more »

2017-05-25 19:05 (0) Answers

How to mock dom element from karma testing

There is an input type file element. During angular file upload multiple times, the value is not being cleared. Hence manually clearing it using plain javascript dom manipulation. Below is the code: function removeFromQueue(item) { vm.uplo...
more »

2017-05-15 09:05 (1) Answers

React testing setup with rails/webpacker

I've added webpacker to my existing rails app, everything is working like a charm. Webpack config is found under config/webpack/shared.js config/webpack/development.js config/webpack/production.js node_modules are installed in vendor/node_module...
more »

2017-02-10 17:02 (1) Answers

Angular 2 JWT Unit Testing

My API calls are authenticated with JWT. I am trying to write code for a service method. All requests has this interceptor: public interceptBefore(request: InterceptedRequest): InterceptedRequest { // Do whatever with request: get info or ed...
more »

2017-02-10 04:02 (1) Answers

Angular Unit Testing Factory Injection

I've seen this answered but none of the solutions are working for me. I'm getting an error Error: [ng:areq] Argument 'fn' is not a function, got undefined which is causing my test to fail. What's the correct way to inject a factory into a test spec t...
more »

2016-10-25 21:10 (1) Answers

cannot npm install karma-ng-html2js-preprocessor

I have found out an annoying problem about the captioned module. When I install karma-ng-html2js-preprocessor, it always ends in the following error: >fsevents@0.2.1 install /Library/WebServer/Documents/node_modules/fsevents >node-gyp rebuild...
more »

2016-08-20 17:08 (1) Answers

spyOn gives method does not exist error

I am running a Karma test on an angular app, in the test I have the following: return inject(function($injector) { this.Service = { functionWithPromise: function(postdata){ var deferred = $q.defer(); deferred.resolve({ ...
more »

2016-07-13 18:07 (1) Answers

karma can I mock service but not include it

My test is running into an error saying the following from and angular site Unknown provider: UserServiceProvider <- UserService <- ResourceService <- taOptions Error: [$injector:unpr]$injector/un...
more »

2016-05-26 18:05 (0) Answers

karma trouble with angular constant

I had working tests before a merge of 2 branches. The new branch brought along an angular constant which I believe broke all the tests. I have an angular constant like so ... return $http.get(ENV+'/api/url').then(function (response) { ...
more »

2016-05-26 18:05 (1) Answers