Skip to content

fix(browser): align browser reporter lifecycle hooks across run and watch#976

Merged
fi3ework merged 2 commits intomainfrom
max/2026-02-25--03-21PM
Feb 25, 2026
Merged

fix(browser): align browser reporter lifecycle hooks across run and watch#976
fi3ework merged 2 commits intomainfrom
max/2026-02-25--03-21PM

Conversation

@fi3ework
Copy link
Copy Markdown
Member

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:

+---------------------------+-----------------------------------------------+------------------------------------------------------+
| Scope                     | Before                                        | After                                                |
+---------------------------+-----------------------------------------------+------------------------------------------------------+
| Browser-only / filtered   | `onTestRunStart` could be skipped             | `onTestRunStart` + `onTestRunEnd` consistently paired|
| Browser lifecycle bridge  | missing file/suite/case lifecycle forwarding  | forwards file-ready/suite-start/case-start/suite-result |
| Watch rerun (browser)     | reruns could miss run-level lifecycle hooks   | each rerun emits run start/end with rerun filtering  |
+---------------------------+-----------------------------------------------+------------------------------------------------------+

Changes:

  • browser runner lifecycle dispatch expansion
    • add file-ready / suite-start / suite-result / case-start in client + dispatch router
  • host reporter orchestration unification
    • central notifyTestRunStart/notifyTestRunEnd helpers reused by initial run and watch reruns
    • incremental reporter-state updates on file complete; deleted-path cleanup on watch file-set changes
  • regression coverage additions
    • new unit test for dispatch routing in packages/browser/tests/dispatchCapabilities.test.ts
    • new browser-mode reporter fixtures/tests, including watch rerun lifecycle assertions

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +2426 to +2430
await notifyTestRunEnd({
duration: {
totalTime: testTime,
buildTime: 0,
testTime,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@codex fix it.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

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 only onTestRunEnd before timeout)
  • ⚠️ curl -I https://www.google.com | head -n 5 (web lookup attempt blocked by network proxy: CONNECT tunnel failed, response 403)

Committed as:

  • b5b8df1fix(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

View task →

@fi3ework fi3ework force-pushed the max/2026-02-25--03-21PM branch from fb9a72e to 1a15662 Compare February 25, 2026 09:11
@fi3ework fi3ework enabled auto-merge (squash) February 25, 2026 09:18
@fi3ework fi3ework merged commit 96dae7a into main Feb 25, 2026
21 of 25 checks passed
@fi3ework fi3ework deleted the max/2026-02-25--03-21PM branch February 25, 2026 09:58
@fi3ework fi3ework mentioned this pull request Mar 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Reporter lifetime functions not being called in browser mode

1 participant