Implementation:Webdriverio Webdriverio BrowserStack Constants
| Knowledge Sources | |
|---|---|
| Domains | BrowserStack, Configuration |
| Last Updated | 2026-02-12 00:00 GMT |
Overview
The BrowserStack Constants module defines all configuration constants for the BrowserStack service, including API endpoints, environment variable keys, default options, batch sizes, and module hook event names.
Description
This module centralizes all hardcoded values and constant definitions used across the BrowserStack service. It includes: (1) Browser description keys (BROWSER_DESCRIPTION) used for building human-readable session names; (2) Valid app extensions (.apk, .aab, .ipa); (3) Default service options with setSessionName, setSessionStatus, testObservability defaults; (4) API endpoints for data collection, accessibility, log uploads, and funnel instrumentation; (5) Batch configuration (DATA_BATCH_SIZE: 1000, DATA_BATCH_INTERVAL: 2000ms); (6) Environment variable names for JWT tokens, build UUIDs, screenshot settings, rerun configuration, and feature flags; (7) Percy constants for capture modes and DOM-changing command endpoints; (8) AI/healing constants for supported browsers and TCG URLs; (9) Module hook events (MODULE_HOOK_EVENTS) mapping lifecycle phases for instrumentation, testhub, observability, Percy, accessibility, AI, local, and app automate modules.
Usage
Import specific constants as needed across all BrowserStack service modules. These are read-only values that configure behavior throughout the service lifecycle.
Code Reference
Source Location
- Repository: Webdriverio_Webdriverio
- File: packages/wdio-browserstack-service/src/constants.ts
- Lines: 1-192
Signature
// Browser capability keys for description building
export const BROWSER_DESCRIPTION: readonly string[]
// Valid mobile app file extensions
export const VALID_APP_EXTENSION: string[]
// Default service configuration
export const DEFAULT_OPTIONS: Partial<BrowserstackConfig>
// API endpoints
export const DATA_ENDPOINT: string // 'https://collector-observability.browserstack.com'
export const APP_ALLY_ENDPOINT: string // 'https://app-accessibility.browserstack.com/automate'
export const UPLOAD_LOGS_ADDRESS: string // 'https://upload-observability.browserstack.com'
export const FUNNEL_INSTRUMENTATION_URL: string // 'https://api.browserstack.com/sdk/v1/event'
export const EDS_URL: string // 'https://eds.browserstack.com'
export const TCG_URL: string // 'https://tcg.browserstack.com'
// Batch configuration
export const DATA_BATCH_SIZE: number // 1000
export const DATA_BATCH_INTERVAL: number // 2000
// Percy capture modes
export const CAPTURE_MODES: string[] // ['click', 'auto', 'screenshot', 'manual', 'testcase']
// Supported browsers for AI healing
export const SUPPORTED_BROWSERS_FOR_AI: string[] // ['chrome', 'microsoftedge', 'firefox']
// Environment variable keys
export const BROWSERSTACK_TESTHUB_JWT: string
export const BROWSERSTACK_TESTHUB_UUID: string
export const BROWSERSTACK_OBSERVABILITY: string
export const BROWSERSTACK_PERCY: string
export const BROWSERSTACK_ACCESSIBILITY: string
// Module lifecycle hook event names
export const MODULE_HOOK_EVENTS: Record<string, string>
Import
import {
BROWSER_DESCRIPTION,
VALID_APP_EXTENSION,
DEFAULT_OPTIONS,
DATA_ENDPOINT,
DATA_BATCH_SIZE,
DATA_BATCH_INTERVAL,
CAPTURE_MODES,
MODULE_HOOK_EVENTS,
SUPPORTED_BROWSERS_FOR_AI,
BROWSERSTACK_TESTHUB_JWT,
BROWSERSTACK_TESTHUB_UUID
} from './constants.js'
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| package.json version | string |
Yes | The BSTACK_SERVICE_VERSION is derived from the package.json version at module load time
|
Outputs
| Name | Type | Description |
|---|---|---|
| All exported constants | number | string[] | object | Read-only configuration values used across the service |
| BSTACK_SERVICE_VERSION | string |
Dynamic service version string from package.json |
| DEFAULT_OPTIONS | Partial<BrowserstackConfig> |
Default values: { setSessionName: true, setSessionStatus: true, testObservability: true, accessibility: false }
|
| MODULE_HOOK_EVENTS | Record<string, string> |
22 performance event names for module lifecycle tracking |
Usage Examples
Using default options in service constructor
import { DEFAULT_OPTIONS } from './constants.js'
this._options = { ...DEFAULT_OPTIONS, ...options }
// Result: setSessionName=true, setSessionStatus=true, testObservability=true, accessibility=false
// plus any user overrides
Checking valid app extensions
import { VALID_APP_EXTENSION } from './constants.js'
if (VALID_APP_EXTENSION.includes(path.extname(app.app!))) {
// Upload the app file to BrowserStack
}
Using environment variable keys
import { BROWSERSTACK_TESTHUB_JWT, BROWSERSTACK_TESTHUB_UUID } from './constants.js'
if (process.env[BROWSERSTACK_TESTHUB_JWT]) {
// Authenticated - can make API calls
}
const buildUrl = `https://automation.browserstack.com/builds/${process.env[BROWSERSTACK_TESTHUB_UUID]}`