-
-
Notifications
You must be signed in to change notification settings - Fork 155
fix(ClientRequest): inherit the connection _handle for passthrough requests
#706
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
05f8a41
48b958a
239cf19
454eaf8
85bd08f
41b7559
bce8f12
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| /** | ||
| * @vitest-environment node | ||
| */ | ||
| import { vi, it, expect, beforeAll, afterAll } from 'vitest' | ||
| import http from 'http' | ||
| import { HttpServer } from '@open-draft/test-server/http' | ||
| import { ClientRequestInterceptor } from '../../../../src/interceptors/ClientRequest' | ||
| import { | ||
| waitForClientRequest, | ||
| } from '../../../helpers' | ||
|
|
||
| const httpServer = new HttpServer((app) => { | ||
| app.get('/', (_req, res) => { | ||
| let count = 1 | ||
| const i = setInterval(() => { | ||
| res.write('a') | ||
| if (++count > 20) { | ||
| clearInterval(i) | ||
| res.end() | ||
| } | ||
| }, 10) | ||
| }) | ||
| }) | ||
|
|
||
| const interceptor = new ClientRequestInterceptor() | ||
|
|
||
| beforeAll(async () => { | ||
| interceptor.apply() | ||
| await httpServer.listen() | ||
| }) | ||
|
|
||
| afterAll(async () => { | ||
| interceptor.dispose() | ||
| await httpServer.close() | ||
| }) | ||
|
|
||
| it('does ', async () => { | ||
| const url = httpServer.http.url('/') | ||
| const warningListener = vi.fn() | ||
| process.on('warning', warningListener) | ||
|
||
|
|
||
| const req = http.get(url) | ||
| const { text } = await waitForClientRequest(req) | ||
|
|
||
| expect(await text()).toBe('a'.repeat(20)) | ||
| expect(warningListener).not.toHaveBeenCalled() | ||
| }) | ||
Uh oh!
There was an error while loading. Please reload this page.