| 5 | describe('Axios', () => { |
| 6 | describe('handle un-writable error stack', () => { |
| 7 | const testUnwritableErrorStack = async (stackAttributes) => { |
| 8 | const axios = new Axios({}); |
| 9 | // Mock axios._request to return an Error with an un-writable stack property. |
| 10 | axios._request = () => { |
| 11 | const mockError = new Error('test-error'); |
| 12 | Object.defineProperty(mockError, 'stack', stackAttributes); |
| 13 | throw mockError; |
| 14 | }; |
| 15 | |
| 16 | try { |
| 17 | await axios.request('test-url', {}); |
| 18 | } catch (e) { |
| 19 | assert.strictEqual(e.message, 'test-error'); |
| 20 | } |
| 21 | }; |
| 22 | |
| 23 | it('should support errors with a defined but un-writable stack', async () => { |
| 24 | await testUnwritableErrorStack({ value: {}, writable: false }); |