本文整理汇总了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);
});