Skip to content

Instantly share code, notes, and snippets.

@paztek
Created July 17, 2020 23:23
Show Gist options
  • Save paztek/b4c36cdabada44124fa521f5af113fbc to your computer and use it in GitHub Desktop.
Save paztek/b4c36cdabada44124fa521f5af113fbc to your computer and use it in GitHub Desktop.
nestjs-ioc-example-3
import { INestApplication } from '@nestjs/common';
import { Test } from '@nestjs/testing';
import { DrinkModule } from './drink.module';
import { SpiritModule } from './spirit/spirit.module';
import { BeerModule } from './beer/beer.module';
import { DrinkService } from './drink.service';
describe('DrinkService', () => {
let app: INestApplication;
let drinkService: DrinkService;
beforeAll(async () => {
const moduleRef = await Test.createTestingModule({
imports: [
DrinkModule,
SpiritModule,
BeerModule,
],
}).compile();
app = moduleRef.createNestApplication();
await app.init();
drinkService = moduleRef.get(DrinkService);
});
it('returns the full list of drinks', async () => {
const drinks = await drinkService.getDrinks();
expect(drinks).toHaveLength(7);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment