Currently, I am in the midst of creating a GUI for an application that is still undergoing API development. Although I have a vision of how it will look, it lacks functionality as of now. Hence, I need to replicate its behavior until the API is fully functional.
To achieve this, I am exploring the usage of $httpBackend
. My setup involves using Yeoman.
Installation Attempt
My Angular version is v1.2.6.
The documentation presents three methods for installation:
- Google CDN at
//ajax.googleapis.com/ajax/libs/angularjs/X.Y.Z/angular-mocke2e.js
- Bower via
bower install <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="25444b425049445708484a464e401740657d0b7c0b7f">[email protected]</a>
- code.angularjs.org:
//code.angularjs.org/X.Y.Z/angular-mocke2e.js
Where X.Y.Z
represents my specific version number.
Unfortunately, none of these approaches seem to work. Google results in a 404 error and does not allow directory traversal. Bower indicates no available package, with a 404 on code.angularjs.org. Upon further investigation on code.angularjs.org, I discovered that for version 1.2.6, there is a lack of angular-mock availability
However, I did manage to locate a file at
https://code.angularjs.org/1.2.6/angular-mocks.js
, which appears to contain the definition for $httpBackendProvider
.
Upon returning to my Yeoman installation, it seems that angular-mocks.js
was already installed.
Thus, my first query arises: Is this the appropriate resource to utilize $httpBackend?
Utilization Attempt
Subsequently, I attempted to integrate it into my project:
// Manually running the app to check cookies
app.run(['$cookies', '$location', '$rootScope', '$httpBackend', function($cookies, $location, $rootScope, $httpBackend){
// Some stuff....
console.log($httpBackend);
}]);
Regrettably, my app failed to launch, displaying the following error:
Although the app does reveal the contents of $httpBackend
, I pondered if relocating it to a different module might be necessary.
Hence, my second question emerges: Is it common for my app to fail loading when incorporating $httpBackend within the app.run() call?
Furthermore, question 3 arises: During testing, should I segregate my $httpBackend functions into a separate module?
Lastly, I contemplate whether this methodology constitutes the most effective approach for API testing.