Skip to content

Commit

Permalink
Fixed errors when running tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonsaayman committed Mar 10, 2022
1 parent 8038742 commit e52e4db
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
3 changes: 2 additions & 1 deletion lib/adapters/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,8 @@ module.exports = function httpAdapter(config) {

// Handle errors
req.on('error', function handleRequestError(err) {
if (req.aborted && err.code !== AxiosError.ERR_FR_TOO_MANY_REDIRECTS) return;
// @todo remove
// if (req.aborted && err.code !== AxiosError.ERR_FR_TOO_MANY_REDIRECTS) return;
reject(AxiosError.from(err, null, config, req));
});

Expand Down
16 changes: 10 additions & 6 deletions test/unit/adapters/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ describe('supports http with nodejs', 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');
assert.strictEqual(error.message, 'timeout of 250ms exceeded');
done();
}, 300);
});
Expand Down Expand Up @@ -237,6 +237,8 @@ describe('supports http with nodejs', function () {
axios.get('http://localhost:4444/', {
maxRedirects: 3
}).catch(function (error) {
assert.equal(error.code, AxiosError.ERR_FR_TOO_MANY_REDIRECTS);
assert.equal(error.message, 'Maximum number of redirects exceeded');
done();
});
});
Expand All @@ -252,11 +254,13 @@ describe('supports http with nodejs', function () {
maxRedirects: 3,
beforeRedirect: function (options) {
if (options.path === '/foo') {
throw new Error('path not allowed');
throw new Error(
'Provided path is not allowed'
);
}
}
}).catch(function (error) {
assert.equal(error.toJSON().message, 'path not allowed')
assert.equal(error.message, 'Provided path is not allowed');
done();
});
});
Expand Down Expand Up @@ -1087,7 +1091,7 @@ describe('supports http with nodejs', function () {
setTimeout(function () {
assert.equal(success, false, 'request should not succeed');
assert.equal(failure, true, 'request should fail');
assert.equal(error.message, 'Malformed URL tel:484-695-3408');
assert.equal(error.message, 'Unsupported protocol tel:');
done();
}, 300);
})
Expand Down Expand Up @@ -1172,8 +1176,8 @@ describe('supports http with nodejs', function () {
}).finally(function () {
assert.strictEqual(success, false, 'request should not succeed');
assert.strictEqual(failure, true, 'request should fail');
assert.strictEqual(error.code, 'ERR_REQUEST_ABORTED');
assert.strictEqual(error.message, 'error request aborted');
assert.strictEqual(error.code, 'ERR_BAD_RESPONSE');
assert.strictEqual(error.message, 'maxContentLength size of -1 exceeded');
done();
});
});
Expand Down

0 comments on commit e52e4db

Please sign in to comment.