superagent-absolute
v1.0.1
Published
Superagent with absolute URLs.
Downloads
2,724
Maintainers
Readme
Superagent Absolute
Superagent with default absolute URLs.
Tired of writing http://localhost
in front of every superagent request?
With superagent absolute you'll only write it once per host in your whole environment.
Install
npm install superagent-absolute
Usage
var superagent = require('superagent');
var superagentAbsolute = require('superagent-absolute');
var agent = superagent.agent();
global.request = superagentAbsolute(agent)('http://localhost:3030');
Example
const superagent = require('superagent');
const superagentAbsolute = require('superagent-absolute');
const agent = superagent.agent();
const request = superagentAbsolute(agent)('http://localhost:3030');
it('should should display "It works!"', (done) => {
request
.get('/')
.end((err, res) => {
expect(res.status).to.equal(200);
expect(res.body).to.eql({ msg: 'It works!' });
done();
});
});
Requested absolute URLs must start with /
, otherwise they will be treated as relative.
License
MIT © Gerard Rovira Sánchez