mirror of
https://github.com/tenrok/axios.git
synced 2026-06-17 19:21:29 +03:00
fa337332b9
* chore: small fixes to tests * feat: transitional move to vitests * feat: moving unit tests in progress * feat: moving more unit tests over * feat: more tests moved * feat: updated more sections of the http test * chore: wip http tests * chore: wip http tests * chore: more http tests * chore: tests * chore: tests * chore: tests * chore: tests * chore: tests * chore: tests * chore: tests * chore: tests * chore: tests * chore: tests * chore: tests * chore: tests * chore: tests * chore: tests * chore: tests * chore: tests * chore: tests * chore: tests * chore: tests * chore: tests * chore: tests * chore: tests * chore: tests * chore: tests * chore: tests * chore: remove un-needed docs * chore: update package lock * chore: update lock
55 lines
1.7 KiB
JavaScript
55 lines
1.7 KiB
JavaScript
/* eslint-env mocha */
|
|
import Axios from '../../../lib/core/Axios.js';
|
|
import assert from 'assert';
|
|
|
|
describe('Axios', function () {
|
|
describe('handle un-writable error stack', function () {
|
|
async function testUnwritableErrorStack(stackAttributes) {
|
|
const axios = new Axios({});
|
|
// mock axios._request to return an Error with an un-writable stack property
|
|
axios._request = () => {
|
|
const mockError = new Error('test-error');
|
|
Object.defineProperty(mockError, 'stack', stackAttributes);
|
|
throw mockError;
|
|
};
|
|
try {
|
|
await axios.request('test-url', {});
|
|
} catch (e) {
|
|
assert.strictEqual(e.message, 'test-error');
|
|
}
|
|
}
|
|
|
|
it('should support errors with a defined but un-writable stack', async function () {
|
|
await testUnwritableErrorStack({ value: {}, writable: false });
|
|
});
|
|
|
|
it('should support errors with an undefined and un-writable stack', async function () {
|
|
await testUnwritableErrorStack({ value: undefined, writable: false });
|
|
});
|
|
|
|
it('should support errors with a custom getter/setter for the stack property', async function () {
|
|
await testUnwritableErrorStack({
|
|
get: () => ({}),
|
|
set: () => {
|
|
throw new Error('read-only');
|
|
},
|
|
});
|
|
});
|
|
|
|
it('should support errors with a custom getter/setter for the stack property (null case)', async function () {
|
|
await testUnwritableErrorStack({
|
|
get: () => null,
|
|
set: () => {
|
|
throw new Error('read-only');
|
|
},
|
|
});
|
|
});
|
|
});
|
|
|
|
it('should not throw if the config argument is omitted', () => {
|
|
const axios = new Axios();
|
|
|
|
assert.deepStrictEqual(axios.defaults, {});
|
|
});
|
|
});
|