**版本信息: @角度/火7.6.1 @角度/常见”:16.0.0
我试图在我的 Angular 项目中实现单元测试,我已经实现了 Angular/Fire,代码运行完美,但在单元测试时它要求 AngularFireModule(在新版本中已被弃用):
我的认证服务:
import { Injectable } from '@angular/core';
import { from, Observable } from 'rxjs';
import {
Auth,
signInWithEmailAndPassword,
authState,
createUserWithEmailAndPassword,
UserCredential,
} from '@angular/fire/auth';
@Injectable({
providedIn: 'root',
})
export class AuthService {
currentUser$ = authState(this.auth);
constructor(private auth: Auth) {}
signUp(email: string, password: string): Observable<UserCredential> {
return from(createUserWithEmailAndPassword(this.auth, email, password));
}
login(email: any, password: any): Observable<any> {
return from(signInWithEmailAndPassword(this.auth, email, password));
}
logout(): Observable<any> {
return from(this.auth.signOut());
}
}
您有以下情况吗?
import { provideFirebaseApp, initializeApp, getApp } from '@angular/fire/app';
import { getFirestore, provideFirestore } from '@angular/fire/firestore';
imports: [
provideFirebaseApp(() => initializeApp(environment.firebase)),
provideFirestore(() => getFirestore(getApp()))
...
]