Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jasmine Test case failing #866

Open
gigglegirl opened this issue Apr 15, 2019 · 1 comment
Open

Jasmine Test case failing #866

gigglegirl opened this issue Apr 15, 2019 · 1 comment

Comments

@gigglegirl
Copy link

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)
@jbbrwcky
Copy link

You have $window being declared but not injected. Alternativel you could use $provide to mock out $window.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants