diff --git a/types/got/got-tests.ts b/types/got/got-tests.ts index d80d0aadcf..b75155ee75 100644 --- a/types/got/got-tests.ts +++ b/types/got/got-tests.ts @@ -265,8 +265,27 @@ got('https://todomvc.com', { rejectUnauthorized: false }); got('/examples/angularjs', { baseUrl: 'http://todomvc.com' }); got('http://todomvc.com', { headers: { foo: 'bar'} }); got('http://todomvc.com', { cookieJar: new tough.CookieJar() }); + +// Test retry options. got('http://todomvc.com', { retry: 2 }); -got('http://todomvc.com', { retry: { retries: 2, methods: ['GET'], statusCodes: [408, 504], maxRetryAfter: 1 } }); +got('http://todomvc.com', { + retry: { + retries: 2, + methods: ['GET'], + statusCodes: [408, 504], + maxRetryAfter: 1, + errorCodes: ['ETIMEDOUT'] + } +}); +// Test custom retry error code. See https://github.com/sindresorhus/got/blob/9f3a09948ff80057b12af0af60846cc5b8f0372d/test/retry.js#L155 +got('http://todomvc.com', { + retry: { + retries: 1, + methods: ['GET'], + errorCodes: ['OH_SNAP'] + } +}); + got('http://todomvc.com', { throwHttpErrors: false }); got('http://todomvc.com', { hooks: { beforeRequest: [ () => 'foo']} }); diff --git a/types/got/index.d.ts b/types/got/index.d.ts index 09b451f4bb..0c847d6489 100644 --- a/types/got/index.d.ts +++ b/types/got/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for got 9.3 +// Type definitions for got 9.4 // Project: https://github.com/sindresorhus/got#readme // Definitions by: BendingBender // Linus Unnebäck @@ -226,6 +226,10 @@ declare namespace got { methods?: Array<'GET' | 'PUT' | 'HEAD' | 'DELETE' | 'OPTIONS' | 'TRACE'>; statusCodes?: Array<408 | 413 | 429 | 500 | 502 | 503 | 504>; maxRetryAfter?: number; + /** + * Allowed error codes. + */ + errorCodes?: string[]; } interface AgentOptions {