fix(v8): report skipped, hook-aborted tests and hook results in the CLI flow#59
fix(v8): report skipped, hook-aborted tests and hook results in the CLI flow#59kamal-kaur04 wants to merge 5 commits into
Conversation
…LI flow v8 port of the v9 fix, plus the hook-routing backport v8 never received: - beforeHook/afterHook CLI branches: route hook lifecycle to the binary via the TestFramework tracker (gRPC). Without this the v8 CLI flow emits no HookRunStarted/HookRunFinished at all (the legacy Listener -> api/v1/batch path is not functional in the CLI pipeline). - cli/skipReporter (new): reports tests that never reach beforeTest/afterTest (static it.skip, this.skip() in before/beforeEach hooks, suites aborted by a failed before hook) through the tracker using the same INIT_TEST -> TEST PRE -> LOG_REPORT POST -> TEST POST sequence afterTest uses, serialized (wdio does not await reporter hooks) and deduped against started tests. - reporter.onTestSkip CLI branch + service.afterHook skip cascade (port of the legacy insights-handler skip propagation). - Hook results: reading `testResult.status` (nonexistent on TestResult) left hook_result at 'pending', coerced downstream to 'passed' — failed before-hooks produced green builds while CI exited 1. Map from the actual passed/skipped fields. Without these, such tests are invisible on the dashboard and their Automate sessions are never linked to the build. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
loadTestResult only destructured {error, passed}, so skip-reported tests
({passed: false, skipped: true}) rendered as 'failed' on the dashboard.
Live-validated: skipped suites now show as skipped with sessions attributed.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Live end-to-end validation (wdio 8.46 + Chrome/Win11, verified via the Observability API)Baseline — stock
With this PR (packed from
Known v8-specific gaps (kept out of scope here, need a follow-up)
The dominant real-world generator — conditional 🤖 Generated with Claude Code |
…, Map serialization
Three v9 tracker fixes the v8 line never received, each masking the next
(found via live end-to-end validation of the skip-reporting change):
- resolveInstance: create an instance for suite-level hooks and reuse across
the hook->INIT_TEST boundary (port of the v9 implementation). Previously any
worker whose first tracked event was a before-all crashed with
"Cannot read properties of undefined (reading 'setLastTestState')", killing
hook tracking and aborting afterHook before the skip cascade could run.
- trackHookEvents: key hook maps by the short state name (BEFORE_ALL), not the
fully-qualified TestFrameworkState.BEFORE_ALL — the binary looks hooks up by
the short name and dropped every finish with "unable to determine
hook-finished".
- sendTestFrameworkEvent: serialize nested Maps (test_hooks_started/finished)
with a Map-aware replacer; JSON.stringify was flattening them to {} so hook
entries never left the process.
Live-validated: suites aborted by a throwing before-all now report their tests
as skipped with sessions attributed, and hook results (failed/skipped/passed)
reach the dashboard.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Update: all v8 gaps closed — full vector parity with v9 (commits
|
…ied state name matchHookRegex was fed `testFrameworkState.toString()` (`TestFrameworkState.BEFORE_ALL`), which the anchored HOOK_REGEX (^BEFORE_|^AFTER_) never matches, so KEY_HOOK_ID was never set and every hook reached TRA with an empty uuid — unmatchable at ingestion, hooks invisible on the dashboard, and failed hooks unable to flip build status. Match the short state name instead, as v9 does. Live-validated: hooks now render with real uuids and a build whose before-all throws reports status failed. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Final update: hooks now visible + build status correct on v8 (commit
|
…stics - wdio v8 does not set `skipped` on a this.skip() before-all result — it arrives as an error carrying mocha's sync-skip marker, so such hooks rendered as failed on the dashboard (and could fail the build). Treat both shapes as a deliberate skip. Live-validated: skip-hooks report `skipped`, only the genuinely-thrown hook reports `failed`. - batchAndPostEvents: drop the blind `.json()` — an empty 2xx body surfaced as a misleading "Unexpected end of JSON input"; non-2xx already carries got's HTTPError with the status code. - listener: include the failure reason when a batch is marked failed instead of only the event count. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Addendum (commit
|
Why
v8 port of #55, plus the hook-routing backport the v8 line never received. On
v8today, the CLI (gRPC) pipeline for mocha:HookRunStarted/HookRunFinishedat all (the hook-routing fix that landed onmainin 9.29.1 was never backported — hook events still fall through to the legacyListener → api/v1/batchpath, which is not functional in the CLI pipeline);beforeTest/afterTest— staticit.skip,this.skip()insidebefore/beforeEachhooks, and suites aborted by a failedbeforehook — making them invisible on the dashboard and leaving their Automate sessions never linked to the build (session-linking noise in build-stability metrics);testResult.statusdoesn't exist onFrameworks.TestResult, sohook_resultstays'pending'and is coerced to'passed'downstream — a failedbeforehook produces a green build while CI exits 1.What
beforeHook/afterHookCLI branches (backport): route hook lifecycle to the binary via the TestFramework tracker (gRPC), mirroringbeforeTest/afterTest.cli/skipReporter.ts(new, same as fix: report skipped and hook-aborted tests in the CLI flow #55): reports skipped/aborted tests through the tracker using the sameINIT_TEST → TEST PRE → LOG_REPORT POST → TEST POSTsequenceafterTestuses (LOG_REPORT/POSTis what loads the result), serialized through a single chain (wdio doesn't await reporter hooks) with started/reported dedup (runtimethis.skip()already reports viaafterTest).reporter.ts:onTestSkipCLI branch with resolved spec file (events without a file location are rejected downstream) and suite chain viactx.service.ts:afterHookskip cascade for hook-aborted suites (port of the legacy insights-handler propagation);beforeTestmarks started tests.cli/frameworks/wdioMochaTestFramework.ts: hook results mapped from the actual result fields —passed/skipped: true/ else →passed/skipped/failed(v8'sTestResulttype doesn't declareskipped; the runtime carries it, handled via a cast).Validation
npm run build(buf generate + esbuild + tsc) passes on the v8 dependency set.skipReporterunit tests: 6/6 passing.LOG_REPORTresult gate, defer mechanism, reporter suite stack) are identical to v9's.🤖 Generated with Claude Code