angular / angular/angularfire

FirebaseError when using fakeAsync

未關閉
#3,615 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
TypeScript
星號
7.8k
分支
2.2k
平均合併
22 小時 28 分鐘
30 天內合併 PR
6

描述

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

貢獻指南

開啟貢獻指南

研究方向

從提供的 recover-email 程式碼及其 fakeAsync 測試開始,然後檢查 localhost 模擬器執行時 recoverEmail$ 如何到達 Firebase Auth checkActionCode。使用 tick(600) 和 flush(); 重現此失敗;完成表示測試在 fakeAsync 下成功完成,且沒有出現 auth/network-request-failed。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
angular, firebase, typescript
領域
authentication, testing
Issue 類型
缺陷
難度
4/5
預估耗時
3-5 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。