Skip to content

Commit

Permalink
The timeoutErrorMessage property in config not work with Node.js (axi…
Browse files Browse the repository at this point in the history
…os#3580)

* Adding "should respect the timeoutErrorMessage property" test case

Co-authored-by: Will Loo <duibu05@126.com>
  • Loading branch information
duibu05 committed Jan 22, 2021
1 parent fe52a61 commit a2f56b0
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions test/unit/adapters/http.js
Expand Up @@ -57,6 +57,36 @@ describe('supports http with nodejs', function () {
});
});

it('should respect the timeoutErrorMessage property', function (done) {

server = http.createServer(function (req, res) {
setTimeout(function () {
res.end();
}, 1000);
}).listen(4444, function () {
var success = false, failure = false;
var error;

axios.get('http://localhost:4444/', {
timeout: 250,
timeoutErrorMessage: 'oops, timeout',
}).then(function (res) {
success = true;
}).catch(function (err) {
error = err;
failure = true;
});

setTimeout(function () {
assert.strictEqual(success, false, 'request should not succeed');
assert.strictEqual(failure, true, 'request should fail');
assert.strictEqual(error.code, 'ECONNABORTED');
assert.strictEqual(error.message, 'oops, timeout');
done();
}, 300);
});
});

it('should allow passing JSON', function (done) {
var data = {
firstName: 'Fred',
Expand Down

0 comments on commit a2f56b0

Please sign in to comment.