-
Notifications
You must be signed in to change notification settings - Fork 0
/
repro.test.js
34 lines (29 loc) · 998 Bytes
/
repro.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
const supertest = require("supertest");
const { http, HttpResponse } = require("msw");
const { setupServer } = require("msw/node");
const encoder = new TextEncoder();
test("reproduce openHandles issue", async () => {
// Provide the server-side API with the request handlers.
const server = setupServer(
http.get("http://localhost/video", () => {
const stream = new ReadableStream({
start(controller) {
// Encode the string chunks using "TextEncoder".
controller.enqueue(encoder.encode("Brand"));
controller.enqueue(encoder.encode("New"));
controller.enqueue(encoder.encode("World"));
controller.close();
},
});
// Send the mocked response immediately.
return new HttpResponse(stream, {
headers: {
"Content-Type": "text/plain",
},
});
})
);
// Start the interception.
server.listen();
await supertest("http://localhost").get("/video").expect(200);
});