I am trying to retrieve a provider from a testing module in NestJS, but cannot resolve that module when providing it out of a module using an interface.
This is what I have so far:
const moduleFixture: TestingModule = await Test.createTestingModule({
imports: [AppModule],
}).compile()
...
const fooService = moduleFixture.get<FooService>(FooService) // Nest could not find FooService element
When the module exporting the FooService is doing something like this...
@Global()
@Module({
providers: [{ provide: 'IFooService', useClass: FooService }],
exports: [{ provide: 'IFooService', useClass: FooService }],
})
export class FooModule {}
How can I get the FooService instance to be able to call methods directly?
Aucun commentaire:
Enregistrer un commentaire