Skip to content

Commit

Permalink
fix test harness
Browse files Browse the repository at this point in the history
  • Loading branch information
tmthecoder committed Mar 30, 2024
1 parent 373c2c3 commit a7cabbb
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions packages/logging-service/test/app.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import { Test, TestingModule } from '@nestjs/testing';
import { INestMicroservice } from '@nestjs/common';
import { AppModule } from './../src/app.module';
import { MicroserviceOptions, Transport } from '@nestjs/microservices';
import { AppService } from 'src/app.service';
import * as ProtoLoader from '@grpc/proto-loader';
import * as GRPC from '@grpc/grpc-js';
import { LoggingProtoFile } from 'juno-proto';

let app: INestMicroservice;

Expand Down Expand Up @@ -37,18 +39,20 @@ afterAll(() => {
});

describe('AppService', () => {
let service: AppService;

let loggingClient: any;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [AppService],
}).compile();
const proto = ProtoLoader.loadSync([LoggingProtoFile]) as any;

const protoGRPC = GRPC.loadPackageDefinition(proto) as any;

service = module.get<AppService>(AppService);
loggingClient = new protoGRPC.juno.email.EmailService(
process.env.EMAIL_SERVICE_ADDR,
GRPC.credentials.createInsecure(),
);
});

it('should log error messages', () => {
const testMessage = 'Test error';
expect(service.recordError(testMessage)).toBeUndefined();
expect(loggingClient.recordError(testMessage)).toBeUndefined();
});
});

0 comments on commit a7cabbb

Please sign in to comment.