title: How to run websocket tests on circleci
body: <p>I have a node app written in typescript. I am trying to run tests on circle ci. I am able to connect redis server as shown here</p>
  <pre><code>&gt; env NODE_ENV=test jest --runInBand --detectOpenHandles --ci
  
    console.log
      Server is running on PORT 4000
  
        at Server.&lt;anonymous&gt; (src/index.ts:51:60)
  
    console.log
      Redis connected!
  
  </code></pre>
  <p>But everything else fails from there.</p>
  <pre><code> console.log
      socket1 failed on startup for test 1. Retrying...
  
        at tests/events.test.ts:147:17
  
    console.log
      restarted
  
        at setupSockets (tests/events.test.ts:79:21)
  
    console.log
      socket1 failed on startup for test 1. Retrying...
  
        at tests/events.test.ts:147:17
  
    console.log
      restarted
  
        at setupSockets (tests/events.test.ts:79:21)
  </code></pre>
  <p>This is the package.json to run the tests</p>
  <pre><code> &quot;scripts&quot;: {
      &quot;test&quot;: &quot;env NODE_ENV=test jest --runInBand --detectOpenHandles --ci&quot;,
  </code></pre>
  <p>These are some of the tests</p>
  <pre><code>describe(&quot;Control test for socket.io&quot;, () =&gt; {
    test(&quot;server should communicate to client.&quot;, (done) =&gt; {
      setTimeout(() =&gt; {
        sockets[0].once(&quot;test&quot;, (msg: string) =&gt; {
          expect(msg).toBe(&quot;Hello World&quot;);
          done &amp;&amp; done();
        });
        SC[0].emit(&quot;test&quot;, &quot;Hello World&quot;);
      }, 100);
    });
  
    test(&quot;client should communicate to server.&quot;, (done) =&gt; {
      setTimeout(() =&gt; {
        SC[1].on(&quot;test&quot;, (msg) =&gt; {
          done &amp;&amp; done();
          expect(msg).toBe(&quot;Hello Server&quot;);
        });
        sockets[1].emit(&quot;test&quot;, &quot;Hello Server&quot;);
      }, 100);
    });
  });
  </code></pre>