©
本文档使用
php.cn手册 发布
ngMock
The ngMock
module provides support to inject and mock Angular services into unit tests.
此外, ngMock also extends various core ng services such that they can be
inspected and controlled in a synchronous manner within test code.
First include angular-mock.js
in your HTML:
<script src="angular.js">
<script src="angular-mock.js">
You can download this file from the following places:
//ajax.googleapis.com/ajax/libs/angularjs/X.Y.Z/angular-mock.js
bower install angular-mock@X.Y.Z
"//code.angularjs.org/X.Y.Z/angular-mock.js"
where X.Y.Z is the AngularJS version you are running.
Then load the module in your application by adding it as a dependent module:
angular.module('app', ['ngMock']);
With that you're ready to get started!
名称 | 描述 |
---|---|
angular.mock |
Namespace from 'angular-mocks.js' which contains testing related code. |
名称 | 描述 |
---|---|
$exceptionHandlerProvider |
Configures the mock implementation of |
名称 | 描述 |
---|---|
$exceptionHandler |
Mock implementation of |
$log |
Mock implementation of |
$interval |
Mock implementation of the $interval service. |
$httpBackend |
Fake HTTP backend implementation suitable for unit testing applications that use the $http service. |
$timeout |
This service is just a simple decorator for $timeout service that adds a "flush" and "verifyNoPendingTasks" methods. |
名称 | 描述 |
---|---|
angular.mock.TzDate |
注意: this is not an injectable instance, just a globally available mock class of |
名称 | 描述 |
---|---|
angular.mock.dump |
注意: this is not an injectable instance, just a globally available function. |
angular.mock.module |
注意: This function is also published on window for easy access. |
angular.mock.inject |
注意: This function is also published on window for easy access. |