How to use the @nestjs/testing.Test.createTestingModule function in @nestjs/testing

To help you get started, weโ€™ve selected a few @nestjs/testing examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nestjs / config / tests / e2e / validation-schema.spec.ts View on Github external
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',
      );
    }
  });
});
github notadd / notadd / apps / nest-upms / e2e / app / baseInfo / services / logger.service.impl.e2e-spec.ts View on Github external
beforeAll(async () => {
        const module = await Test.createTestingModule({
            imports: [ApplicationModule]
        }).compile();
        app = module.createNestApplication();
        loggerService = app.get(LoggerService);
        await app.init();
    })
    it(`insert`, async () => {
github golevelup / nestjs / packages / common / src / discovery / discovery.spec.ts View on Github external
beforeEach(async () => {
    app = await Test.createTestingModule({
      imports: [DiscoveryModule, ExampleModule]
    }).compile();

    await app.init();
  });
github nestjs / bull / lib / bull.explorer.spec.ts View on Github external
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);
    });
  });
github visual-knight / platform-community-edition / apps / api / src / app / shared / static / static.controller.spec.ts View on Github external
beforeEach(async () => {
    const module: TestingModule = await Test.createTestingModule({
      controllers: [StaticController],
    }).compile();

    controller = module.get(StaticController);
  });
github nrwl / ngrx-workshop-app / apps / api / src / app / app.controller.spec.ts View on Github external
beforeAll(async () => {
    app = await Test.createTestingModule({
      controllers: [AppController],
      providers: [CartService, ProductService, ShippingService]
    }).compile();
  });
github devonfw / my-thai-star / node / src / app / core / configuration / services / configuration.service.spec.ts View on Github external
beforeEach(async () => {
    const module: TestingModule = await Test.createTestingModule({
      providers: [ConfigurationService],
    }).compile();

    service = module.get(ConfigurationService);
  });
github notadd / notadd / apps / nest-upms / e2e / app / baseInfo / services / role.service.impl.e2e-spec.ts View on Github external
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)
github International-Slackline-Association / Rankings-Backend / src / core / database / database.service.spec.ts View on Github external
beforeAll(async () => {
    const module = await Test.createTestingModule(DatabaseModule.forTest(new DynamoDBServices(), undefined)).compile();
    databaseService = module.get(DatabaseService);
  });

@nestjs/testing

Nest - modern, fast, powerful node.js web framework (@testing)

MIT
Latest version published 7 days ago

Package Health Score

91 / 100
Full package analysis

Similar packages