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

Commit f539fb1

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 2dcb5ac commit f539fb1

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.
@@ -2250,6 +2251,48 @@ angular.mock.$ComponentControllerProvider = ['$compileProvider', function($compi
22502251
*
22512252
* <div doc-module-components="ngMock"></div>
22522253
*
2254+
* @installation
2255+
*
2256+
* <p>First, download the file:</p>
2257+
* <ul>
2258+
<li>
2259+
<a href="https://developers.google.com/speed/libraries/devguide#angularjs">Google CDN</a> e.g.
2260+
{% code %}"//ajax.googleapis.com/ajax/libs/angularjs/X.Y.Z/"{% endcode %}
2261+
</li>
2262+
<li>
2263+
<a href="https://www.npmjs.com/">NPM</a> e.g.
2264+
{% code %}npm install {$ doc.packageName $}@X.Y.Z{% endcode %}
2265+
</li>
2266+
<li>
2267+
<a href="http://bower.io">Bower</a><br> e.g.
2268+
{% code %}bower install {$ doc.packageName $}@X.Y.Z{% endcode %}
2269+
</li>
2270+
<li>
2271+
<a href="https://code.angularjs.org/">code.angularjs.org</a> (discouraged for
2272+
production use) e.g.
2273+
{% code %}"//code.angularjs.org/X.Y.Z/{$ doc.packageFile $}"{% endcode %}
2274+
</li>
2275+
</ul>
2276+
<p>where X.Y.Z is the AngularJS version you are running.</p>
2277+
2278+
<p>Then, configure your test runner to load `angular-mocks.js` after `angular.js`.
2279+
This example uses <a href="http://karma-runner.github.io/">Karma</a>:</p>
2280+
2281+
{% code %}
2282+
config.set({
2283+
files: [
2284+
'build/angular.js', // and other module files you need
2285+
'build/angular-mocks.js',
2286+
'<path/to/application/files>',
2287+
'<path/to/spec/files>'
2288+
]
2289+
});
2290+
{% endcode %}
2291+
2292+
<p>Including the `angular-mocks.js` file automatically adds the `ngMock` module, so your tests
2293+
are ready to go!</p>
2294+
*
2295+
*
22532296
*/
22542297
angular.module('ngMock', ['ng']).provider({
22552298
$browser: angular.mock.$BrowserProvider,

0 commit comments

Comments
 (0)