fix(cli): send absolute test_file_path and make binary update version-aware (SDK-7233) - #135
Open
Bhargavi-BS wants to merge 2 commits into
Open
fix(cli): send absolute test_file_path and make binary update version-aware (SDK-7233)#135Bhargavi-BS wants to merge 2 commits into
Bhargavi-BS wants to merge 2 commits into
Conversation
…-aware (SDK-7233) WebdriverIO-mocha test results never reached Test Reporting when the project was not a git checkout. test_file_path was gated on a resolvable git root, so outside a git checkout it went out as undefined. The binary dereferences that field in MochaModule.makeFileDetails (path.relative) and throws before the event is uploaded, so every TestRunStarted/TestRunFinished was dropped while CBTSessionCreated still went through — sessions appeared on the dashboard but the test rows never resolved. Send the absolute spec path instead. The binary re-bases it itself against pathProject and versionControlInfo.root (its local is named absoluteTestFilePath), so a pre-relativised value also produced a wrong file_name. The binary-side guard for this has shipped since 1.22.x, but affected users never received it: downloadLatestBinary short-circuits when a binary merely exists on disk, never comparing versions. It is only ever reached after the server reports an update, so the binary it finds is stale by construction and the update is skipped on every run — pinning a machine to the first binary it ever downloaded. Compare against the target version instead, preferring the server-reported one so a custom BROWSERSTACK_BINARY_URL keeps its peer-race handling. Also fixes two latent faults on the same path: a fetch failure left the download promise pending forever, and the write stream's error listener was registered after the first await, so an early failure surfaced as an uncaught exception in the user's test process.
Collaborator
|
RUN_TESTS |
|
[SDK Wdio Test] TRA build state: failed | Stability 98% — verdict: success. Passed: 83, Failed: 2, Aggregate: 85. TRA: https://observability.browserstack.com/builds/0jfhn295feazexlwljrhhxqehpj3jkbtx8kbofoe |
rounak610
requested review from
AakashHotchandani and
dandonarahul2002
and removed request for
Dalwin-Barnard and
rounak610
August 13, 2026 09:31
| import { TestFrameworkConstants } from './constants/testFrameworkConstants.js' | ||
| import { BStackLogger as logger } from '../cliLogger.js' | ||
| import type { Frameworks } from '@wdio/types' | ||
| import { getGitMetaData, getMochaTestHierarchy, getUniqueIdentifier, isUndefined, removeAnsiColors } from '../../util.js' |
Collaborator
There was a problem hiding this comment.
verified if getGitMetaData is not used anywhere else?
dandonarahul2002
approved these changes
Aug 13, 2026
AakashHotchandani
approved these changes
Aug 13, 2026
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?
WebdriverIO-mocha test results never reached Test Reporting when the customer's project was not a git checkout. The dashboard showed sessions but no tests, and the build never resolved.
Three things, in a chain:
test_file_pathwas gated on a resolvable git root (wdioMochaTestFramework.ts). Outside a git checkout it went out asundefined.MochaModule.makeFileDetails(path.relative(root, undefined)) and throws beforeuploadEventData. EveryTestRunStarted/TestRunFinishedwas dropped whileCBTSessionCreatedstill went through — hence sessions present, test rows never resolving. In the reported build: 36 emitted, 0 queued.downloadLatestBinaryshort-circuits when a binary merely exists on disk, never comparing versions. It is only ever reached after the server reports an update, so the binary it finds is stale by construction and the update is skipped on every run — pinning a machine to the first binary it ever downloaded. The reported log shows the 1.48.0 update detected and skipped 1 ms later.Fixes
pathProjectandversionControlInfo.root(its local is literally namedabsoluteTestFilePath), so a pre-relativised value also produced a wrongfile_name. Sending absolute fixes delivery and the rendered path with no binary change.updated_cli_versionso a customBROWSERSTACK_BINARY_URL(no version in the filename) keeps its peer-race handling instead of re-downloading every run.fetchfailure left the download promise pending forever (hanging the launcher), and the write stream'serrorlistener was registered after the firstawait, so an early failure surfaced as an uncaught exception in the user's test process.Verification — three builds against BrowserStack, same non-git project, all on the customer's exact 1.22.1 binary, only the service package changed:
skippedin progress)passedpassedThe updater fix was verified on the real path too: unpatched left the binary at 1.22.1 (reproducing the reported log line exactly); patched downloaded and landed 1.48.0.
file_namenow renders astest/specs/smoke/homePage.test.jsrather than a../../../..path.1085/1085tests,tsc --noEmitandeslintclean.Related Jira task/s
https://browserstack.atlassian.net/browse/SDK-7233
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)
wdioMochaTestFramework:test_file_pathis now the absolute spec path instead of a git-root-relative one (andundefinedwhen no git root). The binary re-bases it againstpathProject/versionControlInfo.root, soundefinedthrew inmakeFileDetailsand dropped everyTestRunStarted/TestRunFinished, and a relative value produced a wrongfile_name. Removed the now-deadgetGitMetaData()call from both emitter sites.cliUtils.downloadLatestBinary: the "binary already exists" short-circuits (post-lock and lock-wait) now require the on-disk binary to match the target version. Previously they tested existence + size only and, since the function is reached only after the server reports an update, always returned the stale binary. Takesupdated_cli_versionexplicitly so a customBROWSERSTACK_BINARY_URLdoesn't lose peer-race handling.cliUtils.downloadLatestBinary:processDownload()now has a.catch()(afetchfailure previously left the promise pending forever), and the write-streamerrorlistener moved before the firstawait(an early stream error had no listener → uncaught exception).Checklist
PR Validations
Run Tests: Comment RUN_TESTS to trigger sanity tests.