The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

plorent (27) [Avatar] Offline
At the end of chapter 3 you show how to test a controller. But, when adding the test to the project, it fails with Error: [$injector:unpr]$injector/unpr?p0=%24scopeProvider%20%3C-%20%24scope%20%3C-%20StoryboardCtrl

describe('StoryboardCtrl', function() {

  var ctrl;


    ctrl = $controller('StoryboardCtrl', {});
    ctrl.detailsForm = {
      $setPristine: function(){},
      $setUntouched: function(){}

  it('should reset the form', function() {
    ctrl.editedStory = ctrl.currentStory = { assignee: '1' };


Would be nice if this test passes. Can you help?
Lukas Ruebbelke (107) [Avatar] Offline
I found one problem with your code, and that was
should have been
Once I fixed that error, your test passed fine for me. I believe this is, in fact, not a testing issue but an issue of injecting
somewhere it is not allowed. It is only available for injection in controllers and the link function of directives. I would go through your code and make sure you aren't injecting it somewhere incorrectly, say in a filter or config block. Here is a Stack Overflow question for reference: Hope this helps!
plorent (27) [Avatar] Offline
Wow, a dumb typo, sorry about that.
I've added the test to the code I pulled from GitHub and it still fails for me after correcting the typo. Don't get that but I will try and figure it out. Thanks for the quick response!

plorent (27) [Avatar] Offline
Found it but it's kind of a funny story. So, looking at the tests in the project, I was thinking 'better do a deep dive into testing with ngMock' and so I did. Few days later, coming back to Angello, I looked at the code and noticed that - in the above posted code - the controller gets initialised with an empty object. Looking at the implementation of the controller I did see dependencies so that's obviously why the test failed. So, how could this be working properly then for you... At some point I thought, well, let's have a look at the GitHub repository and then I realised - maybe a branch? And indeed! A branch for chapter 3! smilie
Well, the good thing is, now I'm a ninja in ngMock!