How to use the @nestjs/typeorm.getRepositoryToken function in @nestjs/typeorm

To help you get started, we’ve selected a few @nestjs/typeorm 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 jmcdo29 / testing-nestjs / apps / typeorm-sample / src / cat / cat.service.spec.ts View on Github external
beforeEach(async () => {
    const module: TestingModule = await Test.createTestingModule({
      providers: [
        CatService,
        {
          provide: getRepositoryToken(Cat),
          // define all the methods that you use from the catRepo
          // give proper return values as expected or mock implementations, your choice
          useValue: {
            find: jest.fn().mockResolvedValue(catArray),
            findOneOrFail: jest.fn().mockResolvedValue(oneCat),
            create: jest.fn().mockReturnValue(oneCat),
            save: jest.fn(),
            // as these do not actually use their return values in our sample
            // we just make sure that their resolee is true to not crash
            update: jest.fn().mockResolvedValue(true),
            // as these do not actually use their return values in our sample
            // we just make sure that their resolee is true to not crash
            delete: jest.fn().mockResolvedValue(true),
          },
        },
      ],
github jmcdo29 / testing-nestjs / apps / typeorm-sample / src / cat / cat.service.create-mock.spec.ts View on Github external
beforeEach(async () => {
    const module = await Test.createTestingModule({
      providers: [
        CatService,
        {
          provide: getRepositoryToken(Cat),
          useValue: createMock>(),
        },
      ],
    }).compile();

    service = module.get(CatService);
    repo = module.get>(getRepositoryToken(Cat));
  });
github xmlking / ngx-starter-kit / apps / api / src / app / project / kubernetes / kubernetes.service.spec.ts View on Github external
beforeAll(async () => {
    const module: TestingModule = await Test.createTestingModule({
      imports: [CacheModule, ConfigModule],
      providers: [
        KubernetesService,
        ClusterService,
        {
          provide: getRepositoryToken(Cluster),
          useValue: mockRepository,
        },
      ],
    }).compile();
    service = module.get(KubernetesService);
  });
  it('should be defined', () => {
github devonfw / my-thai-star / node / src / management / order / order.service.spec.ts View on Github external
const IngredientRepository = new Repository();
    const DishRepository = new Repository();
    const OrderLineRepository = new Repository();
    const module: TestingModule = await Test.createTestingModule({
      providers: [
        OrderService,
        {
          provide: getRepositoryToken(Order),
          useValue: orderRepository,
        },
        {
          provide: getRepositoryToken(Ingredient),
          useValue: IngredientRepository,
        },
        {
          provide: getRepositoryToken(Dish),
          useValue: DishRepository,
        },
        {
          provide: getRepositoryToken(OrderLine),
          useValue: OrderLineRepository,
        },
        {
          provide: BookingService,
          useClass: BookingServiceMock,
        },
      ],
    }).compile();
    service = module.get(OrderService);
  });
  it('should be defined', () => {
github wix / quix / quix-frontend / service / src / modules / web-api / web-api.spec.ts View on Github external
DbFileTreeNode,
              DbFolder,
              DbNote,
              DbNotebook,
              DbAction,
              DbUser,
              DbFavorites,
            ]),
          inject: [ConfigService],
        }),
      ],
      providers: [],
      exports: [],
    }).compile();

    notebookRepo = module.get(getRepositoryToken(DbNotebook));
    noteRepo = module.get(getRepositoryToken(NoteRepository));
    eventsRepo = module.get(getRepositoryToken(DbAction));
    fileTreeRepo = module.get(getRepositoryToken(FileTreeRepository));
    folderRepo = module.get(getRepositoryToken(DbFolder));
    favoritesRepo = module.get(getRepositoryToken(DbFavorites));
    userRepo = module.get(getRepositoryToken(DbUser));
    folderService = module.get(FoldersService);
    notebookService = module.get(NotebookService);
    favoritesService = module.get(FavoritesService);
    conn = module.get(getConnectionToken());
    configService = module.get(ConfigService);
  });
github wix / quix / quix-frontend / service / src / modules / event-sourcing / quix-event-bus.driver.ts View on Github external
const eventBus: QuixEventBus = module.get(QuixEventBus);
    const notebookRepo: Repository = module.get(
      getRepositoryToken(DbNotebook),
    );
    const noteRepo: Repository = module.get(getRepositoryToken(DbNote));
    const eventsRepo: Repository = module.get(
      getRepositoryToken(DbAction),
    );
    const fileTreeRepo: FileTreeRepository = module.get(
      getRepositoryToken(FileTreeRepository),
    );
    const folderRepo: Repository = module.get(
      getRepositoryToken(DbFolder),
    );
    const favoritesRepo: Repository = module.get(
      getRepositoryToken(DbFavorites),
    );
    const conn: Connection = module.get(getConnectionToken());
    const configService: ConfigService = module.get(ConfigService);

    return new QuixEventBusDriver(
      eventBus,
      module,
      noteRepo,
      notebookRepo,
      eventsRepo,
      folderRepo,
      fileTreeRepo,
      favoritesRepo,
      conn,
      configService,
      defaultUser,
github wix / quix / quix-frontend / service / src / modules / event-sourcing / quix-event-bus.driver.ts View on Github external
EventSourcingModule,
      ],
      providers: [],
      exports: [],
    }).compile();

    const eventBus: QuixEventBus = module.get(QuixEventBus);
    const notebookRepo: Repository = module.get(
      getRepositoryToken(DbNotebook),
    );
    const noteRepo: Repository = module.get(getRepositoryToken(DbNote));
    const eventsRepo: Repository = module.get(
      getRepositoryToken(DbAction),
    );
    const fileTreeRepo: FileTreeRepository = module.get(
      getRepositoryToken(FileTreeRepository),
    );
    const folderRepo: Repository = module.get(
      getRepositoryToken(DbFolder),
    );
    const favoritesRepo: Repository = module.get(
      getRepositoryToken(DbFavorites),
    );
    const conn: Connection = module.get(getConnectionToken());
    const configService: ConfigService = module.get(ConfigService);

    return new QuixEventBusDriver(
      eventBus,
      module,
      noteRepo,
      notebookRepo,
      eventsRepo,
github wix / quix / quix-frontend / service / src / modules / web-api / web-api.spec.ts View on Github external
DbAction,
              DbUser,
              DbFavorites,
            ]),
          inject: [ConfigService],
        }),
      ],
      providers: [],
      exports: [],
    }).compile();

    notebookRepo = module.get(getRepositoryToken(DbNotebook));
    noteRepo = module.get(getRepositoryToken(NoteRepository));
    eventsRepo = module.get(getRepositoryToken(DbAction));
    fileTreeRepo = module.get(getRepositoryToken(FileTreeRepository));
    folderRepo = module.get(getRepositoryToken(DbFolder));
    favoritesRepo = module.get(getRepositoryToken(DbFavorites));
    userRepo = module.get(getRepositoryToken(DbUser));
    folderService = module.get(FoldersService);
    notebookService = module.get(NotebookService);
    favoritesService = module.get(FavoritesService);
    conn = module.get(getConnectionToken());
    configService = module.get(ConfigService);
  });
github wix / quix / quix-frontend / service / src / modules / web-api / web-api.spec.ts View on Github external
DbUser,
              DbFavorites,
            ]),
          inject: [ConfigService],
        }),
      ],
      providers: [],
      exports: [],
    }).compile();

    notebookRepo = module.get(getRepositoryToken(DbNotebook));
    noteRepo = module.get(getRepositoryToken(NoteRepository));
    eventsRepo = module.get(getRepositoryToken(DbAction));
    fileTreeRepo = module.get(getRepositoryToken(FileTreeRepository));
    folderRepo = module.get(getRepositoryToken(DbFolder));
    favoritesRepo = module.get(getRepositoryToken(DbFavorites));
    userRepo = module.get(getRepositoryToken(DbUser));
    folderService = module.get(FoldersService);
    notebookService = module.get(NotebookService);
    favoritesService = module.get(FavoritesService);
    conn = module.get(getConnectionToken());
    configService = module.get(ConfigService);
  });
github wix / quix / quix-frontend / service / src / modules / event-sourcing / quix-event-bus.driver.ts View on Github external
DbFavorites,
              DbUser,
            ]),
          inject: [ConfigService],
        }),
        EventSourcingModule,
      ],
      providers: [],
      exports: [],
    }).compile();

    const eventBus: QuixEventBus = module.get(QuixEventBus);
    const notebookRepo: Repository = module.get(
      getRepositoryToken(DbNotebook),
    );
    const noteRepo: Repository = module.get(getRepositoryToken(DbNote));
    const eventsRepo: Repository = module.get(
      getRepositoryToken(DbAction),
    );
    const fileTreeRepo: FileTreeRepository = module.get(
      getRepositoryToken(FileTreeRepository),
    );
    const folderRepo: Repository = module.get(
      getRepositoryToken(DbFolder),
    );
    const favoritesRepo: Repository = module.get(
      getRepositoryToken(DbFavorites),
    );
    const conn: Connection = module.get(getConnectionToken());
    const configService: ConfigService = module.get(ConfigService);

    return new QuixEventBusDriver(