我的应用运行正常,但我无法让我的测试通过Firebase。
Error: No provider for Token FirebaseAppName!
这是我的规格:
import { TestBed, inject } from '@angular/core/testing';
import { ApiService } from './api.service';
import { HttpModule } from '@angular/http';
import {FIREBASE_PROVIDERS, defaultFirebase, AngularFire} from 'angularfire2';
describe('ApiService', () => {
beforeEach(() => {
const firebaseConfig = {
apiKey: "foo",
authDomain: "bar",
databaseURL: "baz",
storageBucket: "foo",
messagingSenderId: "bar"
}
TestBed.configureTestingModule({
// providers: [ApiService, defaultFirebase(firebaseConfig)],
providers: [ApiService, FIREBASE_PROVIDERS, defaultFirebase(firebaseConfig)],
imports: [
HttpModule
]
});
});
it('should ...', inject([ApiService], (service: ApiService) => {
expect(service).toBeTruthy();
}));
});
提前致谢。
版本:
"@angular/core": "^2.4.0",
"jasmine-core": "~2.5.2",
"firebase": "^3.7.0",
答案 0 :(得分:0)
尝试configure module而不是提供商
TestBed.configureTestingModule({
providers: [ApiService]
imports: [
HttpModule,
AngularFireModule.initializeApp(firebaseConfig)
]
});