jest-websocket-mock icon indicating copy to clipboard operation
jest-websocket-mock copied to clipboard

Getting The Aggregator-Error on connecting server with client

Open codersharma2001 opened this issue 1 year ago • 0 comments

Whenever I am trying to connect the mocked server with the client , using the await server.connected , in the beforeAll block , at that point I am facing the Aggregator Error . I followed the exact readme https://www.npmjs.com/package/jest-websocket-mock?activeTab=readme , is there any problem the package it facing ?

My Test Case looks like this :


import WS from 'jest-websocket-mock';
import WebSocket from 'ws';

describe("WebSocket server", () => {
  let server, client;

  beforeEach(async () => {
    server = new WS("ws://localhost:1234");
    client = new WebSocket("ws://localhost:1234");
    await server.connected;
  });
  
  afterEach(() => {
    WS.clean();
  });

  it("should connect the client to the server successfully", async () => {
    client.send("hello");
    await expect(server).toReceiveMessage("hello");
    expect(server).toHaveReceivedMessages(["hello"]);
  });
});

The Error Looks like : image

codersharma2001 avatar Jul 15 '24 09:07 codersharma2001