mardi 3 septembre 2019

Cannot get response from ws server connection - e2e testing

I am attempting to use the ws npm library in my e2e testing, however when I am setting up the tests and creating a 'server', I cannot seem to get any response upon its connection, nevermind actually getting anything fired in...

I have a beforeAll set up with the standard bits that the docs say:

beforeAll(() => {
  const wss = new WS.Server({ port: 8080 });

  wss.on('connection', function connection(ws) {
    console.log('server connected');
    ws.on('message', function incoming(message) {
      console.log('received: %s', message);
      messages.push(message);
    });

    ws.send('something');
  });
});

I added a console.log('server connected'); just to check that the server is actually being set up and even that doesn’t fire?

Aucun commentaire:

Enregistrer un commentaire