Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 36374e6

Browse files
committed
docs($httpBackend): add module declaration for best understanding
According with the Issue #9537. This module declaration in the test is very important. When I started to test in angular I copy and paste this code to see how it works, and I get this `module undefined error`, and just after read some blog posts I figure out that this line is essential for testing your module. So, for best understanding of begginers this can be very helpful.
1 parent 4474633 commit 36374e6

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/ngMock/angular-mocks.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -994,6 +994,11 @@ angular.mock.dump = function(object) {
994994
* First we create the controller under test:
995995
*
996996
```js
997+
// The module code
998+
angular
999+
.module('MyApp')
1000+
.controller('MyController', MyController);
1001+
9971002
// The controller code
9981003
function MyController($scope, $http) {
9991004
var authToken;
@@ -1022,6 +1027,9 @@ angular.mock.dump = function(object) {
10221027
// testing controller
10231028
describe('MyController', function() {
10241029
var $httpBackend, $rootScope, createController, authRequestHandler;
1030+
1031+
// Set up the module
1032+
beforeEach(module('MyApp'));
10251033
10261034
beforeEach(inject(function($injector) {
10271035
// Set up the mock http service responses

0 commit comments

Comments
 (0)