# angular.mock.service.$browser

Work in Progress This page is currently being revised. It might be incomplete or contain inaccuracies.

## Description

This service is a mock implementation of `angular.service.$browser`. It provides fake implementation for commonly used browser apis that are hard to test, e.g. setTimeout, xhr, cookies.

This implementation is automatically available and replaces regular `$browser` service in tests when `angular-mocks.js` is loaded.

The api of this service is the same as the real `$browser`, except that there are several helper methods available which can be used in tests.

The following apis can be used in tests:

- `$browser.xhr` â enables testing of code that uses the `$xhr service` to make XmlHttpRequests.
- $browser.defer â enables testing of code that uses `$defer service` for executing functions via the `setTimeout` api.