Bug Description
Reproducible By
import * as undici from 'undici';
const mockAgent = new undici.MockAgent();
mockAgent.disableNetConnect();
undici.setGlobalDispatcher(mockAgent);
const mockPool = mockAgent.get('https://example.com');
mockPool
.intercept({
path: '/',
})
.reply((request) => {
console.log(request);
return { statusCode: 200 };
});
await undici.request('https://example.com/', {
headers: {
authorization: 'Bearer 123',
},
});
Expected Behavior
The types should be correct.
Logs & Screenshots
Actual value:
{
headers: { authorization: 'Bearer 123' },
origin: 'https://example.com',
path: '/',
method: 'GET'
}
Expected value:
|
reply<TData extends object = object>(replyOptionsCallback: MockInterceptor.MockReplyOptionsCallback<TData>): MockScope<TData>; |
|
export type MockReplyOptionsCallback<TData extends object = object> = ( |
|
opts: MockResponseCallbackOptions |
|
) => { statusCode: number, data?: TData | Buffer | string, responseOptions?: MockResponseOptions } |
|
export interface MockResponseCallbackOptions { |
|
path: string; |
|
origin: string; |
|
method: string; |
|
body?: BodyInit | Dispatcher.DispatchOptions['body']; |
|
headers: Headers | Record<string, string>; |
|
maxRedirections: number; |
|
} |
Environment
Darwin 21.5.0 Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:37 PDT 2022; root:xnu-8020.121.3~4/RELEASE_ARM64_T6000 arm64
{
node: '16.15.1',
v8: '9.4.146.24-node.21',
uv: '1.43.0',
zlib: '1.2.11',
brotli: '1.0.9',
ares: '1.18.1',
modules: '93',
nghttp2: '1.47.0',
napi: '8',
llhttp: '6.0.4',
openssl: '1.1.1o+quic',
cldr: '40.0',
icu: '70.1',
tz: '2021a3',
unicode: '14.0',
ngtcp2: '0.1.0-DEV',
nghttp3: '0.1.0-DEV'
}
Additional context
Bug Description
Reproducible By
Expected Behavior
The types should be correct.
Logs & Screenshots
Actual value:
Expected value:
undici/types/mock-interceptor.d.ts
Line 26 in 1822ee6
undici/types/mock-interceptor.d.ts
Lines 85 to 87 in 1822ee6
undici/types/mock-interceptor.d.ts
Lines 72 to 79 in 1822ee6
Environment
Darwin 21.5.0 Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:37 PDT 2022; root:xnu-8020.121.3~4/RELEASE_ARM64_T6000 arm64
Additional context