![](/img/trans.png)
[英]Jest test error: An update to form inside a test was not wrapped in act when testing local storage
我正在編寫一個測試,用於檢查注銷時是否成功調用了 removeItem。 測試通過但我得到一個錯誤“測試中的 LoginForm 沒有包裝在 act(...) 中”。 這是 LoginForm 組件代碼: 我認為這是異步函數的問題,並嘗試將 expect 語句包裝在 await waitFor()) ...