Open ziw opened 3 years ago
@ziw would love to know if you ever figured this out. I'm writing e2e tests and have tried both overrideProviders
:
const moduleFixture: TestingModule = await Test.createTestingModule({
imports: [AppModule],
})
.overrideProvider(FIREBASE_ADMIN_INJECT)
.useValue({})
.compile();
app = moduleFixture.createNestApplication();
and passing providers
:
const MockFirebaseProvider = {
provide: FIREBASE_ADMIN_INJECT,
useFactory: async () => {
return {};
},
};
const moduleFixture: TestingModule = await Test.createTestingModule({
imports: [AppModule],
providers: [MockFirebaseProvider],
})
.compile();
app = moduleFixture.createNestApplication();
but in both cases I get a similar error to you:
Nest can't resolve dependencies of the AnimalsService (?). Please make sure that the argument FIREBASE_ADMIN_INJECT at index [0] is available in the AnimalsModule context.
Potential solutions:
- If FIREBASE_ADMIN_INJECT is a provider, is it part of the current AnimalsModule?
- If FIREBASE_ADMIN_INJECT is exported from a separate @Module, is that module imported within AnimalsModule?
hi, what's the proper way to inject FIREBASE_ADMIN_INJECT in unit tests? I have a controller
and in its unit test I'm getting error
Nest can't resolve dependencies of the UsersController (?). Please make sure that the argument FIREBASE_ADMIN_INJECT at index [0] is available in the RootTestModule context.