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

Commit b5983e4

Browse files
committed
docs(ngMock): add custom installation instructions
ngMock should be used in a test runner context, not directly in the application Closes #14248
1 parent f30b0ed commit b5983e4

File tree

1 file changed

+44
-1
lines changed

1 file changed

+44
-1
lines changed

src/ngMock/angular-mocks.js

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* @description
77
*
88
* Namespace from 'angular-mocks.js' which contains testing related code.
9+
*
910
*/
1011
angular.mock = {};
1112

@@ -17,7 +18,7 @@ angular.mock = {};
1718
* @description
1819
* This service is a mock implementation of {@link ng.$browser}. It provides fake
1920
* implementation for commonly used browser apis that are hard to test, e.g. setTimeout, xhr,
20-
* cookies, etc...
21+
* cookies, etc.
2122
*
2223
* The api of this service is the same as that of the real {@link ng.$browser $browser}, except
2324
* that there are several helper methods available which can be used in tests.
@@ -2251,6 +2252,48 @@ angular.mock.$ComponentControllerProvider = ['$compileProvider', function($compi
22512252
*
22522253
* <div doc-module-components="ngMock"></div>
22532254
*
2255+
* @installation
2256+
*
2257+
* <p>First, download the file:</p>
2258+
* <ul>
2259+
<li>
2260+
<a href="https://developers.google.com/speed/libraries/devguide#angularjs">Google CDN</a> e.g.
2261+
{% code %}"//ajax.googleapis.com/ajax/libs/angularjs/X.Y.Z/"{% endcode %}
2262+
</li>
2263+
<li>
2264+
<a href="https://www.npmjs.com/">NPM</a> e.g.
2265+
{% code %}npm install {$ doc.packageName $}@X.Y.Z{% endcode %}
2266+
</li>
2267+
<li>
2268+
<a href="http://bower.io">Bower</a><br> e.g.
2269+
{% code %}bower install {$ doc.packageName $}@X.Y.Z{% endcode %}
2270+
</li>
2271+
<li>
2272+
<a href="https://code.angularjs.org/">code.angularjs.org</a> (discouraged for
2273+
production use) e.g.
2274+
{% code %}"//code.angularjs.org/X.Y.Z/{$ doc.packageFile $}"{% endcode %}
2275+
</li>
2276+
</ul>
2277+
<p>where X.Y.Z is the AngularJS version you are running.</p>
2278+
2279+
<p>Then, configure your test runner to load `angular-mocks.js` after `angular.js`.
2280+
This example uses <a href="http://karma-runner.github.io/">Karma</a>:</p>
2281+
2282+
{% code %}
2283+
config.set({
2284+
files: [
2285+
'build/angular.js', // and other module files you need
2286+
'build/angular-mocks.js',
2287+
'<path/to/application/files>',
2288+
'<path/to/spec/files>'
2289+
]
2290+
});
2291+
{% endcode %}
2292+
2293+
<p>Including the `angular-mocks.js` file automatically adds the `ngMock` module, so your tests
2294+
are ready to go!</p>
2295+
*
2296+
*
22542297
*/
22552298
angular.module('ngMock', ['ng']).provider({
22562299
$browser: angular.mock.$BrowserProvider,

0 commit comments

Comments
 (0)