Angularjs is not able to find my controller

tusharmath

I am using angular-mock to inject my controller for unit testing. I am failing to do so since I keep getting the following error.

 [$injector:unpr] Unknown provider: PatientRecordsControllerProvider <- PatientRecordsController

Here is my code setup -

    (function () {
angular.module('patient_profile', ['ngRoute']);
    })();


(function () {
    var PatientRecordsController = function () {

    };

    angular.module('patient_profile').controller('PatientRecordsController', PatientRecordsController);
})();

And my test case

    describe('PatientRecordsController:unit-testing', function () {

    beforeEach(module('patient_profile'));

    it('timeline should be an array', inject(['PatientRecordsController',
        function (controller) {
            //Cant do stuff
        }
    ]));

});

UPDATE The same procedure works perfectly fine with services. How come?

dmahapatro

Controller has to be instantiated using $controller service. Isn't the below format of test cleaner?

describe('PatientRecordsController:unit-testing', function () {
    var controller;

    beforeEach(function(){
        module('patient_profile');

        inject(function(_$controller_){
            controller = _$controller_('PatientRecordsController', {});
        });
    });

    it('timeline should be an array', function(){
        //DO STUFF using controller
    });
});

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

AngularJS can't find my controller

From Dev

AngularJS test, can't find my controller

From Dev

My AngularJS view is able to access it's controller's scope, but ng-repeat doesn't work

From Dev

My AngularJS view is able to access it's controller's scope, but ng-repeat doesn't work

From Dev

angularjs - can not find the controller

From Dev

Not able to access controller variables on view using {{}} in angularjs

From Dev

Not able to access form from controller in AngularJS

From Dev

Spring boot Controller is not able to find the bean class

From Dev

angularjs - controller not loading my scenario

From Dev

Angularjs controller is breaking my expressions

From Dev

Angularjs controller is breaking my expressions

From Dev

Scrapy is not able to find my spiders in the current project

From Dev

Not able to find my object created for DesiredCapabilities class

From Dev

Trying to get my Resolve to inject into my controller to be able to inject into the HTML

From Dev

not able to assign dropdown select value in angularjs controller.

From Dev

Not able to lazily update a controller scope with a REST service - Angularjs

From Dev

Not able to invoke the API Services when something is between Controller and Service in AngularJS?

From Dev

Not able to retrieve ajax data in controller - Laravel 5.2, AngularJs

From Dev

Unable to access property of an object in an angularjs controller but able to access it from the HTML

From Dev

Can't able to connect my controller with html properly in Angular js

From Dev

AngularJS issues with injecting a new service into my controller

From Dev

Cannot inject $ionicHistory into my angularjs controller

From Dev

AngularJS: What is wrong with this injection into my controller?

From Dev

can't access $routeParams in my angularjs controller

From Dev

Not able to find an API for getting BSE stock quote for my Android app

From Dev

Serializer is not able to find my business classes and throws HazelcastSerializationException/ClassNotFoundException

From Dev

Why isn't Rails able to find my installed gem?

From Dev

Not able to find data from my mongodb collection using $nearSphere

From Dev

Not able to find an API for getting BSE stock quote for my Android app

Related Related

  1. 1

    AngularJS can't find my controller

  2. 2

    AngularJS test, can't find my controller

  3. 3

    My AngularJS view is able to access it's controller's scope, but ng-repeat doesn't work

  4. 4

    My AngularJS view is able to access it's controller's scope, but ng-repeat doesn't work

  5. 5

    angularjs - can not find the controller

  6. 6

    Not able to access controller variables on view using {{}} in angularjs

  7. 7

    Not able to access form from controller in AngularJS

  8. 8

    Spring boot Controller is not able to find the bean class

  9. 9

    angularjs - controller not loading my scenario

  10. 10

    Angularjs controller is breaking my expressions

  11. 11

    Angularjs controller is breaking my expressions

  12. 12

    Scrapy is not able to find my spiders in the current project

  13. 13

    Not able to find my object created for DesiredCapabilities class

  14. 14

    Trying to get my Resolve to inject into my controller to be able to inject into the HTML

  15. 15

    not able to assign dropdown select value in angularjs controller.

  16. 16

    Not able to lazily update a controller scope with a REST service - Angularjs

  17. 17

    Not able to invoke the API Services when something is between Controller and Service in AngularJS?

  18. 18

    Not able to retrieve ajax data in controller - Laravel 5.2, AngularJs

  19. 19

    Unable to access property of an object in an angularjs controller but able to access it from the HTML

  20. 20

    Can't able to connect my controller with html properly in Angular js

  21. 21

    AngularJS issues with injecting a new service into my controller

  22. 22

    Cannot inject $ionicHistory into my angularjs controller

  23. 23

    AngularJS: What is wrong with this injection into my controller?

  24. 24

    can't access $routeParams in my angularjs controller

  25. 25

    Not able to find an API for getting BSE stock quote for my Android app

  26. 26

    Serializer is not able to find my business classes and throws HazelcastSerializationException/ClassNotFoundException

  27. 27

    Why isn't Rails able to find my installed gem?

  28. 28

    Not able to find data from my mongodb collection using $nearSphere

  29. 29

    Not able to find an API for getting BSE stock quote for my Android app

HotTag

Archive