title: Jasmine TypeScript test Angular
body: <p>I'm trying to write some Angular Controller tests for my App in Type Script for couple of days and without any success. Before i start i would like to mention that this is the first time that i'm writting test i jasmine. My problem is that i can't mock dependent service in order to test controller. Any help or point to right direction would be good.</p>
  
  <p>Angular Module :</p>
  
  <pre><code> angular.module('some.module', ['ui.router', 'ngAnimate', 'ui.bootstrap', 'pascalprecht.translate', 'ngCookies', 'smart-table']);
  </code></pre>
  
  <p>Angular Controller :</p>
  
  <pre><code>module App.Controllers {
  
  export class TestController{
      static $inject = ["$scope","SomeService"];
      WhatController: () =&gt; string;
      constructor(private $scope: App.IAppScope, private SomeService) {
          var vm = this;
          vm.WhatController = function (): string {
              return SomeService.someAction();
          };
      }
  }
  
  angular.module("some.module").controller("TestController", TestController);
  </code></pre>
  
  <p>}</p>
  
  <p>Angular Service :</p>
  
  <pre><code>module App.Services {
  
  export class SomeService{
      httpService: ng.IHttpService;
      static $inject = ["$http"];
      someAction: () =&gt; any;
  
      constructor($http: ng.IHttpService) {
          var service = this;
          service.someAction= () =&gt; {
             return "test";
          }
      }
  }
  
  factory.$inject = ['$http'];
  function factory($http: ng.IHttpService) {
      return new SomeService($http);
  }
  
  angular.module('some.module').factory('SomeService', factory);
  </code></pre>
  
  <p>}</p>
  
  <p>Karma File :</p>
  
  <pre><code>    module.exports = function (config) {
      config.set({
          basePath: 'Scripts',
          frameworks: ['jasmine', 'jasmine-matchers'],
          files: [
  
              { pattern: 'angular.js', included: true },
              { pattern: 'angular-mocks.js', included: true },
              { pattern: 'angular-ui-router.js', included: true },
              { pattern: 'angular-ui/ui-bootstrap-tpls.js', included: true },
              { pattern: 'angular-animate.js', included: true },
              { pattern: 'angular-translate.js', included: true },
              { pattern: 'angular-translate-loader-url.js', included: true },
              { pattern: 'angular-cookies.js', included: true },
              { pattern: 'smart-table.js', included: true },
  
              '../app/app.module.js',
              '../app/pages/**/*.controller.js',
  
              //Here are controller files
              { pattern: '../app/pages/**/*.spec.js', included: true },
  
          ],
          exclude: ['**/*min.js'],
          preprocessors: {
              '../app/pages/**/*.controller.js': ['coverage'],
          },
  
          reporters: ['progress', 'coverage'],
          port: 9876,
          colors: true,
          logLevel: config.LOG_INFO,
          autoWatch: true,
          browsers: ['PhantomJS'],
          singleRun: true,
  
          coverageReporter: {
          type : 'html',
          dir : 'coverage/'
      }
      })
  }
  </code></pre>
  
  <p>Test :</p>
  
  <pre><code>    'use strict';
  describe("complaints.controller.test", () =&gt; {
      var $http: ng.IHttpService;
      var mockSomeServices: App.Services.SomeServices;
      var mock = angular.mock;
  
  
      beforeEach(() =&gt; {
          mock.module('ui.router');
          mock.module('ngAnimate');
          mock.module('ui.bootstrap');
          mock.module('pascalprecht.translate');
          mock.module('ngCookies');
          mock.module('smart-table');
        });
  
      //This don't work mockSomeServices  is undefined
      beforeEach(mock.inject((_$http_, $injector) =&gt; {
          $http = _$http_;
          mockSomeServices = $injector.get('SomeServices');
      }));
  
     //This also don't work mockSomeServices  is undefined
      beforeEach(mock.inject((_$http_, $injector, SomeServices) =&gt; {
          $http = _$http_;
          mockSomeServices = SomeServices;
      }));
  });
  </code></pre>