浏览代码

[frontend] Fix missing act() in AlertComponent tests

Johan Åhlén 1 年之前
父节点
当前提交
d9ae00d22f
共有 1 个文件被更改,包括 6 次插入2 次删除
  1. 6 2
      desktop/core/src/desktop/js/reactComponents/AlertComponent/AlertComponent.test.tsx

+ 6 - 2
desktop/core/src/desktop/js/reactComponents/AlertComponent/AlertComponent.test.tsx

@@ -98,11 +98,15 @@ describe('AlertComponent', () => {
     expect(screen.queryAllByRole('alert')).toHaveLength(1);
 
     //It should still be open after 2 seconds
-    jest.advanceTimersByTime(2000);
+    act(() => {
+      jest.advanceTimersByTime(2000);
+    });
     expect(screen.queryAllByRole('alert')).toHaveLength(1);
 
     //After 3.1 seconds, it should really be closed
-    jest.advanceTimersByTime(1000);
+    act(() => {
+      jest.advanceTimersByTime(1000);
+    });
     expect(screen.queryAllByRole('alert')).toHaveLength(0);
 
     jest.useRealTimers();