Angular 6 NG test with Angularfirestore.
Hey guys.
My code works fine with angularfire2 firestore.
But my spec file fails in test.
As soon as i add
constructor(private afs: AngularFirestore) { }
in my components constructor my tests fail
NullInjectorError: No provider for AngularFirestore
But even when i add AngularFirestore my spec file testBed like this
import { AngularFirestoreModule } from 'angularfire2/firestore';
TestBed.configureTestingModule({
declarations: [MyComponent],
providers: [AngularFirestoreModule]```
I still get the same error.
This is my app.module
import { AngularFireModule } from 'angularfire2';
import { AngularFirestoreModule } from 'angularfire2/firestore';
import { environment } from '../environments/environment';
@NgModule({
declarations: [
AppComponent
],
imports: [
// firebase modules
AngularFireModule.initializeApp(environment.firebase),
AngularFirestoreModule
],
providers: [],
})
export class AppModule { }
PLease help.
Here is a link to my repository
https://github.com/acc2link/Angular6
One thing that looks odd to me is your app.module has AngularFirestoreModule under imports, but your test file has it under providers. Is it supposed to be consistent? Also, if you put it under providers is it supposed to be AngularFirestore instead of AngularFirestoreModule?
When i put AngularFirestore as provider in my test I get
No provider for InjectionToken angularfire2.app.options!
Thanks @jsparks19 .. My version of angular is 6.
Created a new issue https://github.com/angular/angularfire2/issues/1706
https://github.com/angular/angularfire2/issues/1706#issuecomment-394212606