diff --git a/axios/http-client.js b/axios/http-client.js index 28f86e3..615827f 100644 --- a/axios/http-client.js +++ b/axios/http-client.js @@ -22,7 +22,7 @@ module.exports = ({ // insecureHTTPParser: false, transitional: { clarifyTimeoutError: true, - forcedJSONParsing: false, + // forcedJSONParsing: false, silentJSONParsing: false, }, headers, diff --git a/tests/http/http-timeout.test.js b/tests/http/http-timeout.test.js index fb4379a..160e68f 100644 --- a/tests/http/http-timeout.test.js +++ b/tests/http/http-timeout.test.js @@ -1,6 +1,16 @@ -const {client} = global.t +const {jsonClient} = global.t test('basic http test', async () => { - const {status} = await client({timeout: 100}).post('/long', {}) + const {post} = jsonClient({timeout: 100}) + await expect(post('/long', {})).rejects.toMatchObject({ + code: 'ETIMEDOUT', + timeout: 100, + status: 408, + message: 'Timed out.', + }) +}) + +test('timeout is ok', async () => { + const {status} = await jsonClient({timeout: 500}).post('/long', {}) expect(status).toEqual(200) }) diff --git a/tests/http/setup-http.js b/tests/http/setup-http.js index f63dd0d..425fc62 100644 --- a/tests/http/setup-http.js +++ b/tests/http/setup-http.js @@ -10,7 +10,7 @@ const {start, stop, client} = testFastifyServer(app) tracerFastifyLogger({app, logLevel: 'debug'}) app.setErrorHandler(httpErrorHandler()) -global.t = {client} +global.t = {client, jsonClient: client} beforeAll(start) afterAll(stop)