Files
nest/integration/microservices/e2e/sum-grpc.spec.ts
2018-05-25 12:48:38 +02:00

42 lines
1.0 KiB
TypeScript

import { INestApplication } from '@nestjs/common';
import { Transport } from '@nestjs/microservices';
import { Test } from '@nestjs/testing';
import * as express from 'express';
import { join } from 'path';
import * as request from 'supertest';
import { GrpcController } from '../src/grpc/grpc.controller';
describe('GRPC transport', () => {
let server;
let app: INestApplication;
beforeEach(async () => {
const module = await Test.createTestingModule({
controllers: [GrpcController],
}).compile();
server = express();
app = module.createNestApplication(server);
app.connectMicroservice({
transport: Transport.GRPC,
options: {
package: 'math',
protoPath: join(__dirname, './../src/grpc/math.proto'),
},
});
await app.startAllMicroservicesAsync();
await app.init();
});
it(`/POST`, () => {
return request(server)
.post('/')
.send([1, 2, 3, 4, 5])
.expect(200, { result: '15' });
});
afterEach(async () => {
await app.close();
});
});