Explorar el Código

test: drain the detached SubagentStart continuation before the bridge spec ends

The markers are touched mid-script, so runPoint's continuation chain (child
exit → merge → the listener's detached .then) can still be in flight when the
marker poll resolves; a vitest worker that exits first leaves the inject
condition's short-circuit path uncounted. Observed as a CI-only 99.03%
branch-coverage flake on hooks-claude — surfaced by this branch shifting suite
timing, latent before it. Two macrotask rounds pin the path deterministically.
Tianyi Cui hace 3 meses
padre
commit
5a91893b86
Se han modificado 1 ficheros con 8 adiciones y 0 borrados
  1. 8 0
      packages/hooks/hooks-claude/tests/bridge.spec.ts

+ 8 - 0
packages/hooks/hooks-claude/tests/bridge.spec.ts

@@ -298,6 +298,14 @@ describe('hooks-claude bridge — SubagentStart / SubagentStop (observe)', () =>
     await waitFor(() => existsSync(startMarker) && existsSync(stopMarker))
     expect(existsSync(startMarker)).toBe(true)
     expect(existsSync(stopMarker)).toBe(true)
+    // The markers are touched MID-script, so runPoint's continuation chain
+    // (child-exit event → merge → the listener's detached .then) can still be
+    // in flight when the poll resolves. Drain two macrotask rounds so the
+    // short-circuit path of the SubagentStart inject condition executes before
+    // this worker can exit — observed as a CI-only 99.03% branch-coverage
+    // flake on hooks-claude when the worker won the race.
+    await new Promise(resolve => setTimeout(resolve, 0))
+    await new Promise(resolve => setTimeout(resolve, 0))
   })
 })