MCPcopy
hub / github.com/socketio/socket.io / beforeAll

Function beforeAll

packages/engine.io-client/test/support/hooks.js:15–82  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

13
14exports.mochaHooks = {
15 beforeAll() {
16 const app = express();
17 httpServer = createServer(app);
18
19 engine = attach(httpServer, {
20 pingInterval: 500,
21 maxHttpBufferSize: 100,
22 allowRequest: (req, fn) => {
23 const denyRequest = new URL(`http://${req.url}`).searchParams.has(
24 "deny",
25 );
26 fn(null, !denyRequest);
27 },
28 });
29
30 rollup(rollupConfig).then(async (bundle) => {
31 await bundle.write({
32 ...rollupConfig.output,
33 file: "./test/support/public/engine.io.min.js",
34 sourcemap: false,
35 });
36
37 await bundle.close();
38 });
39
40 httpServer.listen(process.env.ZUUL_PORT || 3000);
41
42 // serve worker.js and engine.io.js as raw file
43 app.use("/test/support", express.static(join(__dirname, "public")));
44
45 engine.on("connection", (socket) => {
46 socket.send("hi");
47
48 // Bounce any received messages back
49 socket.on("message", (data) => {
50 if (data === "give binary") {
51 const abv = new Int8Array(5);
52 for (let i = 0; i < 5; i++) {
53 abv[i] = i;
54 }
55 socket.send(abv);
56 return;
57 } else if (data === "give utf8") {
58 socket.send("пойду спать всем спокойной ночи");
59 return;
60 } else if (data === "sendHeaders") {
61 const headers = socket.transport?.dataReq?.headers;
62 return socket.send(JSON.stringify(headers));
63 }
64
65 socket.send(data);
66 });
67 });
68
69 engine.on("initial_headers", (headers) => {
70 headers["set-cookie"] = [
71 serialize("1", "1", { maxAge: 86400 }),
72 serialize("2", "2", {

Callers

nothing calls this directly

Calls 9

createServerFunction · 0.85
attachFunction · 0.85
fnFunction · 0.85
listenMethod · 0.80
writeMethod · 0.45
closeMethod · 0.45
useMethod · 0.45
onMethod · 0.45
sendMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…