Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Test concurrent calls with an agentClass ( mocha runner )
/*jshint node: true*/
"use strict";
process.env.NODE_ENV = 'test';
const assert = require('assert');
const Request = require('request-promise');
const HttpsAgent = require('socks5-https-client/lib/Agent');
const Promise = require('bluebird');
describe('Request', function() {
describe('Test concurrency with agentClass vs agent options', function(){
it('with agentClass option', function(){
return Promise.all([Request({
url: 'https://ipinfo.io/',
json: true,
agentClass: HttpsAgent,
agentOptions: {
socksHost: 'localhost',
socksPort: 9050
}
}),
Request({
url: 'https://ipinfo.io/',
json: true,
agentClass: HttpsAgent,
agentOptions: {
socksHost: 'localhost',
socksPort: 9051
}
})
]).then(results => console.log(results));
});
it('with agent option', function(){
return Promise.all([Request({
url: 'https://ipinfo.io/',
json: true,
agent: new HttpsAgent({
socksHost: 'localhost',
socksPort: 9050
})
}),
Request({
url: 'https://ipinfo.io/',
json: true,
agent: new HttpsAgent({
socksHost: 'localhost',
socksPort: 9051
})
})
]).then(results => console.log(results));
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.