Created
July 17, 2020 23:23
-
-
Save paztek/b4c36cdabada44124fa521f5af113fbc to your computer and use it in GitHub Desktop.
nestjs-ioc-example-3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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