angular / angular/angularfire

FirebaseError when using fakeAsync

Aperta
#3,615 1 commento 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
TypeScript
Stelle
7.8k
Fork
2.2k
Merge medio
22h 28m
PR unite (30g)
6

Descrizione

I'm seeing `Firebase: Error (auth/network-request-failed)` when using `fakeAsync`, but success without using it. (While using the emulator on localhost during test runs.)

```ts
it('should recover email fakeAsync', fakeAsync((): void => {
console.log('START');
service.recoverEmail$(testOobCode).subscribe({
error: fail,
next: (data: RecoverEmailResults): void => {
expect(data).withContext('RecoverEmailResults').toEqual({
passwordResetSent: true,
restoredEmail: testOriginalEmail,
successful: true,
});
},
});

tick(600);
flush(); // Makes the promises actually settle within the test lifetime.
console.log('END');
}));
```
`recoverEmail$` is calling `checkActionCode` (and `applyActionCode`, but it doesn't get there) from Firebase. (`@angular/fire/auth` wrappers, current 19.0.0 version). Best I can tell firebase just uses browser `fetch`, but I cannot find any reports of problems with `fakeAsync` and `fetch` (possibly due to the commonness of the word `fetch` in code discussions).

Full code is here: https://github.com/rgant/brainfry/tree/main/src/app/identity/recover-email

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia con il codice recover-email fornito e il relativo test fakeAsync, quindi esamina come recoverEmail$ raggiunge Firebase Auth checkActionCode mentre l’emulatore localhost è in esecuzione. Riproduci il fallimento con tick(600) e flush(); fatto significa che il test viene completato correttamente con fakeAsync senza auth/network-request-failed.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
angular, firebase, typescript
Ambito
authentication, testing
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.