Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it(`should validate loaded env variables`, async () => {
try {
const module = await Test.createTestingModule({
imports: [AppModule.withSchemaValidation()],
}).compile();
app = module.createNestApplication();
await app.init();
} catch (err) {
expect(err.message).toEqual(
'Config validation error: "PORT" is required. "DATABASE_NAME" is required',
);
}
});
});
beforeAll(async () => {
const module = await Test.createTestingModule({
imports: [ApplicationModule]
}).compile();
app = module.createNestApplication();
loggerService = app.get(LoggerService);
await app.init();
})
it(`insert`, async () => {
beforeEach(async () => {
app = await Test.createTestingModule({
imports: [DiscoveryModule, ExampleModule]
}).compile();
await app.init();
});
it('should return the queue matching the given token', async () => {
const queueToken = getQueueToken('test');
const fakeQueue = 'I am a fake queue';
const module = await Test.createTestingModule({
imports: [BullModule.forRoot({ name: 'test' })],
})
.overrideProvider(queueToken)
.useValue(fakeQueue)
.compile();
const moduleRef = module.get(ModuleRef);
const queue = BullExplorer.getQueue(moduleRef, queueToken);
expect(queue).toBeDefined();
expect(queue).toBe(fakeQueue);
});
});
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
controllers: [StaticController],
}).compile();
controller = module.get(StaticController);
});
beforeAll(async () => {
app = await Test.createTestingModule({
controllers: [AppController],
providers: [CartService, ProductService, ShippingService]
}).compile();
});
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [ConfigurationService],
}).compile();
service = module.get(ConfigurationService);
});
beforeAll(async () => {
const module = await Test.createTestingModule({
imports: [ApplicationModule]
}).compile();
app = module.createNestApplication();
roleService = app.get(RoleService);
async function add(i: number) {
const role = new RoleEntity();
role.name = 'role' + i;
role.title = 'iphone' + i;
role.description = 'ddd' + i;
role.create_time = new Date();
role.update_time = new Date();
await roleService.insert(role).then((result) => { }).catch(e => { });
}
for (let i = 0; i < 10; i++) {
await add(i)
beforeAll(async () => {
const module = await Test.createTestingModule(DatabaseModule.forTest(new DynamoDBServices(), undefined)).compile();
databaseService = module.get(DatabaseService);
});