title: e2e testing a microservice in Nest
body: <p>I'm attempting to write e2e tests for a microservice in Nest.  I think I've got my ProxyClient created properly in order to do requests to the service.</p>
  
  <p>What I'm trying to do in my tests:</p>
  
  <ol>
  <li>Create a proxy client</li>
  <li>Send a message using that client</li>
  <li>Have them message be picked up by the service</li>
  <li>Return the result of the message processing done by the service</li>
  </ol>
  
  <p>Here's what I have so far...it seems like it's close but I keep seeing this when I run my tests.</p>
  
  <blockquote>
    <p>Expected: true, 
        Received: {"_isScalar": false, "operator": {"concurrent": Infinity, "project": [Function anonymous]}, "source": {"_isScalar": false, "_subscribe": [Function anonymous]}}</p>
  </blockquote>
  
  <pre><code>import { Inject } from '@nestjs/common';
  import { Test, TestingModule } from '@nestjs/testing';
  import { ClientsModule, Transport, ClientProxy } from '@nestjs/microservices';
  import * as request from 'supertest';
  import { HeartbeatModule } from './../src/heartbeat.module';
  import { HeartbeatService } from './../src/heartbeat.service';
  
  
  describe('AppController (e2e)', () =&gt; {
    let app;
    let client: ClientProxy;
  
    beforeEach(async () =&gt; {
      const moduleFixture: TestingModule = await Test.createTestingModule({
        imports: [HeartbeatModule, ClientsModule.register([{ name: 'HEARTBEAT_SERVICE', transport: Transport.TCP }])],
      }).compile();
  
      app = moduleFixture.createNestApplication();
      await app.init();
  
      client = app.get('HEARTBEAT_SERVICE');
      await client.connect();
    });
  
    afterAll(async () =&gt; {
      await client.close();
    });
  
    it('sends a level 1 heartbeat message to the HeartbeatService', async () =&gt; {
      const response = client.send({"cmd": "heartbeat"}, {"type": 1});
  
      expect(response).toBe(true);
    });
  });
  </code></pre>