From a2f56b0df14b5b6cdac224c5c556328d4977bf7f Mon Sep 17 00:00:00 2001 From: Will Loo Date: Sat, 23 Jan 2021 01:17:48 +0800 Subject: [PATCH] The timeoutErrorMessage property in config not work with Node.js (#3580) * Adding "should respect the timeoutErrorMessage property" test case Co-authored-by: Will Loo --- test/unit/adapters/http.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/test/unit/adapters/http.js b/test/unit/adapters/http.js index 497eb28f73..6211e42277 100644 --- a/test/unit/adapters/http.js +++ b/test/unit/adapters/http.js @@ -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',