Test level custom metadata#76
Merged
Merged
Conversation
…(beforeEach/afterEach) for WDIO+Mocha Adds correct beforeEach/afterEach hook-timing handling for the setCustomTags feature already on main. WDIO's Mocha runner fires user hooks OUTSIDE the SDK's per-test tracking span: beforeEach runs before beforeTest tracks the test instance, and afterEach runs after afterTest finishes it — so tags set in those hooks previously either landed on the wrong test or missed the payload. - Buffer tags set before a per-test context exists (e.g. from beforeEach) and flush them into the test at test start (a new TEST/PRE observer in CustomTagsModule minting an onBeforeTest flush). - The service layer records the open Mocha hook window (beforeHook/afterHook) so CustomTagsModule can route a setCustomTags call to the right test. - Defer the TestRunFinished (TEST/POST) send past the after-each hook window so tags set in afterEach still make the payload; flushed at the next test's boundary, or from service.after() for the worker's last test. Ports webdriverio PR anish353/webdriverio#3 into the migrated standalone repo, reconciling against pre-existing drift in testHubModule.ts and service.ts. Standalone on main, independent of the title-based-TC work. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
classifyMochaHookTitle matched hook-window phrases with substring .includes()
and checked "before each" first, so a custom-named hook whose title merely
contained another window's phrase (e.g. afterEach('reset before each run') ->
'"after each" hook: reset before each run') was misclassified as before_each and
its tag buffered onto the NEXT test instead of the current one.
Derive the window from getHookType, which anchors on Mocha's generated
'"before each"'/'"after each"' prefix via startsWith. This removes the
duplicated matching logic and guarantees the window and the tracked hook-state
(both computed from the same hook title in service.beforeHook) can never diverge.
Addresses the MEDIUM finding from the PR #60 review. Live-verified: a named
afterEach with a cross-phrase title now routes to the current test
(merged, window=AFTER_EACH) with zero before_each buffering, and the existing
union across body+afterEach is unchanged.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Dalwin-Barnard
requested review from
harshit-browserstack and
yashdsaraf
and removed request for
a team
July 22, 2026 15:57
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is this about?
Related Jira task/s
Release (mandatory for every PR — required for the
ready-for-reviewlabel)Version bump: (required — tick exactly one)
Release notes type: (optional)
Release notes (customer-facing): (optional but encouraged)
Release notes (internal): (required — engineer-facing; what actually changed / why)
Checklist
PR Validations
Run Tests: Comment RUN_TESTS to trigger sanity tests.