diff --git a/types/got/got-tests.ts b/types/got/got-tests.ts index d80d0aadcf..c32c7da121 100644 --- a/types/got/got-tests.ts +++ b/types/got/got-tests.ts @@ -268,7 +268,6 @@ got('http://todomvc.com', { cookieJar: new tough.CookieJar() }); got('http://todomvc.com', { retry: 2 }); got('http://todomvc.com', { retry: { retries: 2, methods: ['GET'], statusCodes: [408, 504], maxRetryAfter: 1 } }); got('http://todomvc.com', { throwHttpErrors: false }); -got('http://todomvc.com', { hooks: { beforeRequest: [ () => 'foo']} }); // Test timeout options. got('http://todomvc.com', {timeout: 1}); @@ -288,6 +287,15 @@ got('http://todomvc.com', { got('http://todomvc.com', {timeout: 1}).catch((err) => err instanceof got.TimeoutError); // Test hooks. +got('example.com', { + hooks: { + beforeRequest: [ + options => { + options.headers!['x-foo'] = 'bar'; + } + ] + } +}); got('example.com', { hooks: { beforeRedirect: [ @@ -339,6 +347,11 @@ got('example.com', { got('example.com', { hooks: { + beforeRequest: [ + async () => { + await doSomethingAsync(); + } + ], beforeRedirect: [ async () => { await doSomethingAsync();