fix(browser): align browser reporter lifecycle hooks across run and watch#976
fix(browser): align browser reporter lifecycle hooks across run and watch#976
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fb9a72eb30
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| await notifyTestRunEnd({ | ||
| duration: { | ||
| totalTime: testTime, | ||
| buildTime: 0, | ||
| testTime, |
There was a problem hiding this comment.
Wait for watch rerun completion before ending run
In headed watch mode this block emits onTestRunEnd immediately after rpcManager.reloadTestFile(...), but that RPC only triggers UI-side iframe reload and returns right away (packages/browser-ui/src/hooks/useRpc.ts and packages/browser-ui/src/main.tsx), so the rerun is still executing when reporters are told the run ended. This can produce stale/partial results/testResults (and miss rerun fatal errors) in reporter output for every rerun in browser UI watch sessions.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Summary
- Updated browser-ui RPC typing so container
reloadTestFileis explicitly asynchronous (Promise<void>), allowing host-side calls to wait for real rerun completion instead of immediate iframe reload dispatch. packages/browser-ui/src/types.tsL126-L129 - Updated
useRpcto treatreloadTestFileasasyncand await the reload callback, preserving promise semantics across birpc boundaries. packages/browser-ui/src/hooks/useRpc.tsL17-L24 packages/browser-ui/src/hooks/useRpc.tsL62-L74 - Added pending rerun tracking in
main.tsx:- stores per-file pending resolvers when a reload starts,
- resolves on
file-complete, - rejects on
fataland component teardown.
This makes rerun RPC completion align with actual rerun lifecycle completion, so hostonTestRunEndtiming is no longer early for watch reruns. packages/browser-ui/src/main.tsxL70-L90 packages/browser-ui/src/main.tsxL190-L230 packages/browser-ui/src/main.tsxL276-L288 packages/browser-ui/src/main.tsxL394-L440
Testing
- ✅
pnpm biome check --write packages/browser-ui/src/main.tsx packages/browser-ui/src/hooks/useRpc.ts packages/browser-ui/src/types.ts - ✅
pnpm --filter @rstest/browser-ui typecheck - ❌
cd e2e && pnpm rstest browser-mode/watchReporter.test.ts(fails in this environment with timeout waiting for initial hook counts; log showed onlyonTestRunEndbefore timeout) ⚠️ curl -I https://www.google.com | head -n 5(web lookup attempt blocked by network proxy:CONNECT tunnel failed, response 403)
Committed as:
b5b8df1—fix(browser-ui): await rerun completion before resolving reload RPC
Also created a follow-up PR message via make_pr with title:
fix(browser-ui): wait for reload reruns to finish before ending watch run
fb9a72e to
1a15662
Compare
Summary
fix #970.
This PR fixes reporter lifecycle inconsistencies in browser mode, especially when running browser-only projects or rerunning in watch mode. It extends the new dispatch pipeline end-to-end so browser runner lifecycle events are forwarded to host reporters, and it unifies run-level hook handling for initial runs and reruns. It also adds targeted unit/e2e coverage to lock behavior and prevent regressions.
Behavior diff:
Changes:
file-ready/suite-start/suite-result/case-startin client + dispatch routernotifyTestRunStart/notifyTestRunEndhelpers reused by initial run and watch rerunspackages/browser/tests/dispatchCapabilities.test.ts