nestjsts-jestnestjs-testing

Can't call useMocker on TestingModule


I'm trying to execute useMocker on the following piece of code:

const module = await Test.createTestingModule({
        providers: [
            RatingService,
            UserService,
            RentService,
            { provide: getRepositoryToken(RatingORM), useValue: repositoryMockFactory(ratingStub()) },
        ],
    }).useMocker((token) => {
        switch(token) {
            case UserService: return UserService;
            case RentService: return RentService;
        }
    }).compile();

but I keep getting the error "Property 'useMocker' does not exist on type 'TestingModuleBuilder'"

Anyone knows why is that?


Solution

  • make sure you're using the right version of @nestjs/testing. Upgrade it to the latest or something