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

Commit 0f6aa10

Browse files
lnmunhozIgorMinar
authored andcommitted
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. Closes #9563
1 parent 3345bf8 commit 0f6aa10

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/ngMock/angular-mocks.js

+8
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;
@@ -1023,6 +1028,9 @@ angular.mock.dump = function(object) {
10231028
describe('MyController', function() {
10241029
var $httpBackend, $rootScope, createController, authRequestHandler;
10251030
1031+
// Set up the module
1032+
beforeEach(module('MyApp'));
1033+
10261034
beforeEach(inject(function($injector) {
10271035
// Set up the mock http service responses
10281036
$httpBackend = $injector.get('$httpBackend');

0 commit comments

Comments
 (0)