@apps/e2e-playwright/tests/focus/quick-focus.spec.ts:36 should collectPageErrors be a global helper instead of only in focus helpers?
Assistant
I'll look at how collectPageErrors is used in the focus suite and whether similar helpers already exist at the global E2E layer.
Assistant
The helper is only imported from focus, but other suites already attach pageerror listeners by hand. Next I’ll compare those copies with the global E2E helpers.
Assistant
Yes. collectPageErrors belongs in a shared E2E util, not in focus-test-helpers.ts. Line 36 is a different helper, though.
What line 36 is doing
collectRuntimeFailures wraps collectPageErrors and then also listens for a quick-focus-specific set of console errors (state_unsafe_mutation, lifecycle_, destroyed, Cannot read properties). That wrapper should stay in quick-focus.spec.ts. It is feature-specific, used only twice in that file.
collectPageErrors itself is generic Playwright plumbing: attach a pageerror listener, push error.message (or stack), return the array.
Why it should be global
It has no focus-domain knowledge, but it currently lives next to session reset, Quick Focus locators, and Google-account blocking. The E2E rules say capability helpers should own capability setup and user workflows, and that generic helpers should not grow unrelated behavior.
Call sites already show the mismatch:
Many focus specs import it from focus-test-helpers.
overview.spec.ts imports onlycollectPageErrors from that file.
Memory, Nucleum calendar, and smoke tests duplicate the same 3-line listener by hand:
That is the same helper, copied because importing from focus-test-helpers would be a capability-layer leak.
Where to put it
A small file under tests/utils/ (alongside locator-assertions.ts) is the better fit. helpers.ts is already navigation/auth/library-heavy; this is an assertion helper, not a workflow helper. Keep the { includeStack?: boolean } option — only objectives/record-page.spec.ts uses it today.
What not to do
Do not turn it into a global Playwright fixture or beforeEach that collects errors on every test. Specs that do not assert pageErrors would start failing on unrelated console noise, and that would force test edits across suites. Keep it opt-in: call it in the test, then expect(pageErrors).toEqual([]).
Leave collectRuntimeFailures and the Nucleum calendar console-error filter local. Those filters are spec-specific; they can compose on top of a shared collectPageErrors.