title: Jest with WebSockets ignores messages after the first one?
body: <p>I am trying to test a WebSockets server. The onMessage handler gets called for the first time only - any further messages published to the server are not logged. Why is this happening?
  `</p>
  
  <pre><code>     const WebSocket = require('ws');
       const ws = new WebSocket(WEBSOCKETS_ENDPOINT);
  
       describe('When a speed test is triggered', () =&gt; {
       test('Then AWS should send the result to the client', done =&gt; {
          ws.on('open', async () =&gt; {
              ws.send(JSON.stringify({
                  message: 'start-speed-test-rbsid',
                  data: RBSID,
                  platform: "android"
              }));
                  ws.on('message', data =&gt; {
                      data = JSON.parse(data)
                      // this gets called only once - any further messages published from the server are not logged
                      console.log(data)
                  });
          })
       })
       afterAll(() =&gt; ws.close())
  </code></pre>
  
  <p>});</p>
  
  <p>Message data should be logged on every message that was published</p>