Skip to content

Jasmine Test case failing  #866

@gigglegirl

Description

@gigglegirl

Please help me with the below code . I am unable to resolve error and my Unit case is not running. Pasting code below. Your help is highly appreciated.

app.js

  var test = angular.module('testApp', [/**/ ]);

Controller file :

     'use strict';
     test.controller('memberCtrl', ['$rootScope', '$scope', 'lpbridgeSerivces', '$timeout', 
    'uiGridConstants', '$log', '$filter', '$http', 'limitToFilter', 'alert', '$transition$', '$window', 
    '$state',  'fileDownloadService','appEnvConfigService', '$uibModal', 
     function($rootScope, $scope, lpbridgeSerivces, $timeout, uiGridConstants, $log, $filter, 
     $http, 
     limitToFilter, alert, $transition$, $window, $state, fileDownloadService, 
     appEnvConfigService, 
     $uibModal) 

     {
      var home = this;
     home.mobDropDown = false;

Spec File

  describe('memberCtrl', function() {
  beforeEach(module('testApp'));

 var $controller,scope,home;
 beforeEach(inject(function(_$controller_,$rootScope){
 $controller = _$controller_;
 scope = $rootScope.$new();
 }));

 describe('testing controller', function() {         
    it('memberCtrl is defined', function() {
    var home = $controller('memberCtrl', { $scope: scope});
    expect(home.mobDropDown).toBe(false);
     });
   });
});

ERROR:

     Chrome 73.0.3683 (Windows 7.0.0) memberCtrl testing controller memberCtrl is defined 
    FAILED
    Error: [$injector:unpr] http://errors.angularjs.org/1.5.8/$injector/unpr?p0=APP_VERSIO
        at node_modules/angular/angular.min.js:6:412
        at node_modules/angular/angular.min.js:43:174
        at Object.d [as get] (node_modules/angular/angular.min.js:40:432)
        at node_modules/angular/angular.min.js:43:236
        at d (node_modules/angular/angular.min.js:40:432)
        at e (node_modules/angular/angular.min.js:41:158)
        at Object.invoke (node_modules/angular/angular.min.js:41:243)
        at node_modules/angular/angular.min.js:43:396
        at q (node_modules/angular/angular.min.js:7:355)
        at Object.cb [as injector] (node_modules/angular/angular.min.js:43:375)
    TypeError: $controller is not a function
        at <Jasmine>
        at UserContext.<anonymous> (test/spec/memberCtrl-spec.js:27:20)
        at <Jasmine>
   Chrome 73.0.3683 (Windows 7.0.0) ERROR
  {
   "message": "An error was thrown in afterAll\nUncaught Error: [$location:nobase] http://err
   "str": "An error was thrown in afterAll\nUncaught Error: [$location:nobase] http://errors.
  }
 Chrome 73.0.3683 (Windows 7.0.0): Executed 1 of 1 (1 FAILED) ERROR (0.113 secs / 0.07 secs)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions