From 753961d6aee4e37a5ecddbf39f5ac0b4311dc51d Mon Sep 17 00:00:00 2001 From: Juan Manuel Palacios Date: Sat, 24 May 2014 03:32:05 -0430 Subject: [PATCH] Karma also needs to be told about ngResource The controllers' unit tests are adapted to work with the Phone service, which uses the ngResource module. But for this to work, Karma's configuration also needs to be told to load the ```angular-resource.js``` file through its karma.conf.js configuration, and any testing runs that may be happening restarted for the change to take effect. Though the diff from step 10 to step 11 does modify the Karma configuration, https://github.com/angular/angular-phonecat/compare/step-10...step-11, the explanation says nothing about it, and the tests will all fail precisely because of a failure to load ngResource for no apparent reason, until it's explicitly made available to Karma through the steps described in this pull request. Feel free to adapt the wording to whatever may be more appropriate, but the extra instructions added in this pull request seem to be absolutely indispensable to get all tests in the green again. An alternative, of course, is to simply ship a ```karma.conf.js``` with ```angular-resource.js``` already loaded in an updated source package, and sidestep this whole problem that arises in step 11 from the start. --- docs/content/tutorial/step_11.ngdoc | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/docs/content/tutorial/step_11.ngdoc b/docs/content/tutorial/step_11.ngdoc index 2935355bfd59..4d3c816ff499 100644 --- a/docs/content/tutorial/step_11.ngdoc +++ b/docs/content/tutorial/step_11.ngdoc @@ -251,7 +251,19 @@ describe('PhoneCat controllers', function() { }); ``` -You should now see the following output in the Karma tab: +For our modified tests to work, however, Karma also has to be told to load the `angular-resource.js` file, +so that the {@link api/ngResource ngResource} module becomes available to the testing framework. + +__`test/karma.conf.js`:__ +```js +... + 'app/bower_components/angular-route/angular-route.js', + 'app/bower_components/angular-resource/angular-resource.js', + 'app/bower_components/angular-mocks/angular-mocks.js', +... +``` + +Once Karma has been restarted through ```npm test```, you should now see the following output in the Karma tab:
Chrome 22.0: Executed 4 of 4 SUCCESS (0.038 secs / 0.01 secs)