-
Notifications
You must be signed in to change notification settings - Fork 9
SDK-7138: add browser.uploadAttachment / uploadMedia to the WebdriverIO service #193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
4eb12b3
ee0a40a
37f672d
817d036
b462687
fc2d81e
10bc360
ba987e2
54cfbbd
e4dc5cd
a5fb1d8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| "@wdio/browserstack-service": patch | ||
| --- | ||
|
|
||
| - Added `browser.uploadAttachment(filePath)` (also available as `browser.uploadMedia`) so WebdriverIO tests can attach files to a test, hook, or build in Test Reporting — the same capability the Java, Python and Node SDKs already offer. Pass `{ buildAttachment: true }` to attach to the build instead of the current test. | ||
| - Made BrowserStack session bootstrap tolerant of an incomplete configuration response. Previously an empty or partial response aborted the whole bootstrap, which silently disabled every BrowserStack feature for that run — including custom tags and Test Reporting — and could leave the build with no test results. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,6 +21,7 @@ import WdioAutomationFramework from './frameworks/wdioAutomationFramework.js' | |
| import WebdriverIOModule from './modules/webdriverIOModule.js' | ||
| import AccessibilityModule from './modules/accessibilityModule.js' | ||
| import CustomTagsModule from './modules/customTagsModule.js' | ||
| import UploadAttachmentModule from './modules/uploadAttachmentModule.js' | ||
| import { isTurboScale, processAccessibilityResponse, shouldAddServiceVersion } from '../util.js' | ||
| import ObservabilityModule from './modules/observabilityModule.js' | ||
| import type { BrowserstackConfig, BrowserstackOptions, LaunchResponse } from '../types.js' | ||
|
|
@@ -184,6 +185,10 @@ export class BrowserstackCLI { | |
| // to TestHub, so it is gated on the testhub pipeline being active. | ||
| this.modules[CustomTagsModule.MODULE_NAME] = new CustomTagsModule() | ||
|
|
||
| // Attachments ride a TEST_ATTACHMENT LogCreated event keyed on the test / | ||
| // hook uuid, so they are gated on the same pipeline. | ||
| this.modules[UploadAttachmentModule.MODULE_NAME] = new UploadAttachmentModule() | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The sibling SDKs never throw here: Python's Fix: always attach a no-op stub (debug log) to the browser, and let
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed, that was the SDK-7138 symptom surviving on every non-testhub path. Fixed in |
||
|
|
||
| if (startBinResponse.accessibility?.success){ | ||
| process.env[BROWSERSTACK_ACCESSIBILITY] = 'true' | ||
| const options = this.options as BrowserstackConfig & BrowserstackOptions | ||
|
|
@@ -529,6 +534,14 @@ export class BrowserstackCLI { | |
| */ | ||
| setConfig(response: StartBinSessionResponse) { | ||
| try { | ||
| // A degenerate bin-session response (auth failure, races on a parallel worker's | ||
| // ConnectBinSession) carries an empty config. JSON.parse would throw, leaving | ||
| // this.config on its previous value and the error indistinguishable from a | ||
| // malformed payload — keep the empty default and say so. | ||
| if (!response.config || !response.config.trim()) { | ||
| this.logger.warn('setConfig: bin session returned an empty config; continuing with defaults') | ||
| return | ||
| } | ||
| this.config = JSON.parse(response.config) | ||
| // Binary now nests apis under config.sessionData; prefer it, fall back to the flat config.apis (SDK-6821 Phase 3) | ||
| const sessionData = this.config.sessionData as { apis?: unknown } | undefined | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This adds a new public API (
browser.uploadAttachment/browser.uploadMedia), so per the PR template it should be aminorbump, notpatch("New features mislabeled as patch is the common mistake — when unsure, choose minor"). The release-notes type should also be New Feature rather than Bug Fix.Fix: tick
minor+ New Feature in the Release section; the changeset regenerates from it.