I used angular-cli to generate my project. This is my test generated by angular-cli and updated to include router, angularmaterial2 and angularfire2
import { async, TestBed } from '@angular/core/testing';
import { MaterialModule } from '@angular/material';
import { RouterModule } from '@angular/router';
import { AngularFireModule, AuthMethods, AuthProviders } from 'angularfire2';
import { } from 'jasmine';
import { AppComponent } from './app.component';
describe('AppComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
MaterialModule.forRoot(),
RouterModule,
AngularFireModule,
],
declarations: [
AppComponent,
],
providers: [
],
}).compileComponents();
}));
it('should create the app', async(() => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
expect(app).toBeTruthy();
}));
});
When I run it I get DI error: Failed: No provider for Token FirebaseUrl! How can I fix this problem?
Configuring AngularFireModule fixed this problem.
beforeEach(async(() => {
const firebaseConfig = {
apiKey: 'xxx',
authDomain: 'xxx',
databaseURL: 'xxx',
storageBucket: 'xxx',
messagingSenderId: 'xxx',
};
TestBed.configureTestingModule({
imports: [
MaterialModule.forRoot(),
RouterModule,
AngularFireModule.initializeApp(firebaseConfig),
],
declarations: [
AppComponent,
],
providers: [
],
}).compileComponents();
}));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With