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

Function beforeAll

packages/engine.io-client/test/support/hooks.js:15–82  ·  packages/engine.io-client/test/support/hooks.js::beforeAll
()

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:class="cm">//${req.url}`).searchParams.has(
24 class="st">"deny",
25 );
26 fn(null, !denyRequest);
27 },
28 });
29
30 rollup(rollupConfig).then(async (bundle) => {
31 await bundle.write({
32 ...rollupConfig.output,
33 file: class="st">"./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 class="cm">// serve worker.js and engine.io.js as raw file
43 app.use(class="st">"/test/support", express.static(join(__dirname, class="st">"public")));
44
45 engine.on(class="st">"connection", (socket) => {
46 socket.send(class="st">"hi");
47
48 class="cm">// Bounce any received messages back
49 socket.on(class="st">"message", (data) => {
50 if (data === class="st">"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 === class="st">"give utf8") {
58 socket.send(class="st">"пойду спать всем спокойной ночи");
59 return;
60 } else if (data === class="st">"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(class="st">"initial_headers", (headers) => {
70 headers[class="st">"set-cookie"] = [
71 serialize(class="st">"1", class="st">"1", { maxAge: 86400 }),
72 serialize(class="st">"2", class="st">"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