Browse Source

test: fixup assertNotWindows (#41045)

* chore: fixup assertNotWindows

* remove logging
John Kleinschmidt 1 year ago
parent
commit
3dafb318a8
1 changed files with 13 additions and 7 deletions
  1. 13 7
      spec/lib/window-helpers.ts

+ 13 - 7
spec/lib/window-helpers.ts

@@ -29,13 +29,19 @@ export const closeWindow = async (
   await ensureWindowIsClosed(window);
 
   if (assertNotWindows) {
-    const windows = BaseWindow.getAllWindows();
-    try {
-      expect(windows).to.have.lengthOf(0);
-    } finally {
-      for (const win of windows) {
-        await ensureWindowIsClosed(win);
-      }
+    let windows = BaseWindow.getAllWindows();
+    if (windows.length > 0) {
+      setTimeout(async () => {
+        // Wait until next tick to assert that all windows have been closed.
+        windows = BaseWindow.getAllWindows();
+        try {
+          expect(windows).to.have.lengthOf(0);
+        } finally {
+          for (const win of windows) {
+            await ensureWindowIsClosed(win);
+          }
+        }
+      });
     }
   }
 };