Skip to content
This repository has been archived by the owner on Aug 30, 2024. It is now read-only.

Commit

Permalink
timeout test is done, and the transitional option are set and tested
Browse files Browse the repository at this point in the history
  • Loading branch information
ildella committed Nov 22, 2023
1 parent 0c63fdc commit 1c2b2de
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion axios/http-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module.exports = ({
// insecureHTTPParser: false,
transitional: {
clarifyTimeoutError: true,
forcedJSONParsing: false,
// forcedJSONParsing: false,
silentJSONParsing: false,
},
headers,
Expand Down
14 changes: 12 additions & 2 deletions tests/http/http-timeout.test.js
Original file line number Diff line number Diff line change
@@ -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)
})
2 changes: 1 addition & 1 deletion tests/http/setup-http.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 1c2b2de

Please sign in to comment.