
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
httpbackendext
Advanced tools
Module for mock http request (http backend) with protractor for testing angular app
Http backend mock module for protractor
npm install httpbackendext
include angular mock script https://github.com/angular/bower-angular-mocks
javascript
var HttpBackend = require('httpbackend');
var backend = null;
describe('Test Http backend methods', function() {
beforeEach(function() {
backend = new HttpBackend(browser);
});
afterEach(function() {
backend.verifyNoOutstandingExpectation();
backend.clear();
});
it('Test when (POST) with function as response', function() {
backend.when('POST', /result/).respond(function(method, url, data) {
return [200, 'abuga'];
});
browser.get('/');
element(by.css('#buttonPOST')).click();
var result = element(by.binding('result'));
expect(result.getText()).toEqual('abuga');
});
it('Test expect function', function() {
backend.expect('POST', /result/);
browser.get('/');
element(by.css('#buttonPOST')).click();
});
it('Test expectGET function', function() {
backend.expectGET(/result/);
browser.get('/');
element(by.css('#buttonGET')).click();
});
it('Test expectPOST function', function() {
backend.expectPOST(/result/);
browser.get('/');
element(by.css('#buttonPOST')).click();
});
it('Test expectPOST and expectGET functions', function() {
backend.expectPOST(/result/);
backend.expectGET(/result/);
browser.get('/');
element(by.css('#buttonPOST')).click();
element(by.css('#buttonGET')).click();
});
it('Test combined when and expect functions', function() {
backend.expectPOST(/result/);
backend.expectGET(/result/);
backend.whenPOST(/result/).respond('raoulPOST');
backend.whenGET(/result/).respond('raoulGET');
browser.get('/');
element(by.css('#buttonPOST')).click();
var result = element(by.binding('result'));
expect(result.getText()).toEqual('raoulPOST');
element(by.css('#buttonGET')).click();
result = element(by.binding('result'));
expect(result.getText()).toEqual('raoulGET');
});
it('Test whenGET with string response', function() {
backend.whenGET(/result/).respond('raoul');
browser.get('http://127.0.0.1:8080');
var result = element(by.binding('result'));
expect(result.getText()).toEqual('raoul');
});
it('Test whenPOST with function as response', function() {
backend.whenPOST(/result/).respond(function(method, url, data) {
return [200, data];
});
browser.get('http://127.0.0.1:8080');
element(by.css('#buttonPOST')).click();
var result = element(by.binding('result'));
expect(result.getText()).toEqual('postedData');
});
});
HttpBackend workflow is quite simple:
when*or when you call manually backend.sync(), fixtures is synchronised with your angularjs app.For perfomance issue you can disable auto sync:
var backend = new HttpBackend(brower, {autoSync: false});
//Then you should manually call sync function
backend.whenGET(/results/).respond('raoul');
backend.whenGET(/responses/).respond('raoul');
backend.sync();
when GET, POST, HEAD, PUT, JSONP add a fixtures, accept literal object, or a callbackexpect GET, POST, HEAD, PUT, JSONP add expectation. verify expectations with backend.verifyNoOutstandingExpectation()sync, manualy sync fixturesclear, clear http backend modulereset, reset all fixtureInit project
bower install
npm install
Launch test
npm test
MIT
FAQs
Module for mock http request (http backend) with protractor for testing angular app
We found that httpbackendext demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.