<commit_before>const {basename} = require('path');
const filename = basename(__filename);

const WebSocket = require('ws');
const {VertexServer, VertexSocket} = require('../');

describe(filename, () => {

  let wsServer, vServer;

  let wsServerSocket, wsSocket, vServerSocket, vSocket;

  before('start websocket server', done => {
    wsServer = new WebSocket.Server({ port: 8080 });
    wsServer.on('listening', done);
  });

  after('stop clients', () => {
    if (wsSocket) wsSocket.close();
    if (vSocket) vSocket.destroy();
  });

  after('stop websocket server', done => {
    wsServer.close(done);
  });

  before('start vertex server', done => {
    VertexServer.listen()
      .then(server => {
        vServer = server;
        done();
      })
      .catch(done);
  });

  after('stop vertex server', done => {
    if (!vServer) return done();
    vServer.close();
    done();
  });

  before('connect websocket client', done => {

    wsServer.on('connection', socket => {
      wsServerSocket = socket;
      done();
    });

    wsSocket = new WebSocket('ws://localhost:8080');

  });

  before('connect vertex client', done => {

    vServer.on('connection', socket => {
      vServerSocket = socket;
      // done();
    });

    VertexSocket.connect()
      .then(client => {
        vSocket = client;
        done();
      })<commit_msg>compare websocket<commit_after>const {basename} = require('path');
const filename = basename(__filename);

const WebSocket = require('ws');
const {VertexServer, VertexSocket} = require('../');

describe(filename, () => {

  let wsServer, vServer;

  let wsServerSocket, wsSocket, vServerSocket, vSocket;

  before('start websocket server', done => {
    wsServer = new WebSocket.Server({ port: 8080 });
    wsServer.on('listening', done);
  });

  after('stop clients', () => {
    if (wsSocket) wsSocket.close();
    if (vSocket) vSocket.destroy();
  });

  after('stop websocket server', done => {
    wsServer.close(done);
  });

  before('start vertex server', done => {
    VertexServer.listen()
      .then(server => {
        vServer = server;
        done();
      })
      .catch(done);
  });

  after('stop vertex server', done => {
    if (!vServer) return done();
    vServer.close();
    done();
  });

  before('connect websocket client', done => {

    wsServer.on('connection', socket => {
      wsServerSocket = socket;
      done();
    });

    wsSocket = new WebSocket('ws://localhost:8080');

  });

  before('connect vertex client', done => {

    vServer.on('connection', socket => {
      vServerSocket = socket;
      // done();
    });

    VertexSocket.connect()
      .then(client => {
        vSocket = client;
        vSocket.write(); // prevent "Inactivity on connect" closing the socket
        done();
      })
{'fraction_non_alphanumeric': 0.17195861576881913, 'fraction_numerical': 0.005708169818052087, 'mean_word_length': 2.8729281767955803, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5075171', 'n_tokens_mistral': 889, 'n_tokens_neox': 822, 'n_words': 193}