本文整理匯總了TypeScript中@nestjs/testing.TestingModule類的典型用法代碼示例。如果您正苦於以下問題:TypeScript TestingModule類的具體用法?TypeScript TestingModule怎麽用?TypeScript TestingModule使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了TestingModule類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: beforeEach
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [ScoreService],
}).compile();
service = module.get<ScoreService>(ScoreService);
});
示例2: beforeEach
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
controllers: [ScoreController],
}).compile();
controller = module.get<ScoreController>(ScoreController);
});
示例3: beforeEach
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
imports: [
JwtModule.register({
secretOrPrivateKey: 'test',
signOptions: {
expiresIn: 3600,
},
}),
PassportModule.register({ defaultStrategy: 'jwt' }),
],
controllers: [AuthController],
providers: [
AuthService,
UserService,
GroupService,
MachineService,
JwtStrategy,
{
provide: ConfigService,
useValue: new ConfigService(`${process.env.NODE_ENV || 'development'}.env`),
},
{ provide: getRepositoryToken(User), useClass: Repository,},
{ provide: getRepositoryToken(Group), useClass: Repository,},
{ provide: getRepositoryToken(Machine), useClass: Repository,},
{ provide: getRepositoryToken(UserGroup), useClass: Repository,},
]
}).compile();
controller = module.get<AuthController>(AuthController);
});
示例4: beforeEach
beforeEach(async () => {
const testModule: TestingModule = await Test.createTestingModule({
providers: [
...databaseProviders,
...dictionaryEntryProviders,
DictinaryEntryService,
DictionaryEntryResolver,
AuthGuard,
{
provide: Types.CONFIG,
useValue: {
mongoConnectionUri: `mongodb://localhost:27017/TEST_${uuidv4()}`,
secureApiToken: 'test_token',
},
},
],
}).compile();
connection = await prepareDatabaseScenario(testModule, [
createDataFor<DictionaryEntryEntity>(DictionaryEntryEntity, [
{ japanese: 'inu', english: 'dog' },
{ japanese: 'neko', english: 'cat' },
]),
]);
dictionaryEntryResolver = testModule.get<DictionaryEntryResolver>(
DictionaryEntryResolver,
);
});
示例5: beforeEach
beforeEach(async () => {
const app: TestingModule = await Test.createTestingModule({
controllers: [AppController],
providers: [AppService],
}).compile()
appController = app.get<AppController>(AppController)
})
示例6: beforeEach
beforeEach(async () => {
const moduleFixture: TestingModule = await Test.createTestingModule({
imports: [AppModule],
}).compile();
app = moduleFixture.createNestApplication();
await app.init();
});
示例7: beforeAll
beforeAll(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [{
provide: ConfigService,
useValue: new ConfigService(`${process.env.NODE_ENV}.env`),
}],
}).compile();
service = module.get<ConfigService>(ConfigService);
});
示例8: beforeAll
beforeAll(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [
ConfigurationService,
{ provide: 'ConfigurationRepository', useClass: ConfigurationRepository },
],
}).compile();
service = module.get<ConfigurationService>(ConfigurationService);
});
示例9: beforeEach
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [
MachineService,
{provide: getRepositoryToken(Machine), useClass: Repository,},
{provide: getRepositoryToken(Group), useClass: Repository,},],
}).compile();
service = module.get<MachineService>(MachineService);
});
示例10: beforeAll
beforeAll(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [
GymnastService,
{ provide: 'GymnastRepository', useClass: GymnastRepository },
{ provide: 'PubSubInstance', useValue: new PubSub() }
],
}).compile();
service = module.get<GymnastService>(GymnastService);
});