浏览代码

fix(test): drain macrotasks via setTimeout, not setImmediate

setImmediate is a Node global not declared in the frontend's DOM tsconfig,
so tsc --noEmit failed with 'Cannot find name setImmediate'. setTimeout is
universally typed and still flushes React's pending setImmediate: looping
the awaits keeps afterEach unresolved across several event-loop iterations,
so the queued check-phase callback fires while window still exists.
MHSanaei 9 小时之前
父节点
当前提交
48f470c465
共有 1 个文件被更改,包括 1 次插入1 次删除
  1. 1 1
      frontend/src/test/setup.components.ts

+ 1 - 1
frontend/src/test/setup.components.ts

@@ -71,6 +71,6 @@ afterEach(async () => {
    * one behind the first.
    */
   for (let i = 0; i < 3; i += 1) {
-    await new Promise((resolve) => setImmediate(resolve));
+    await new Promise((resolve) => setTimeout(resolve, 0));
   }
 });