File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -162,6 +162,7 @@ export async function allowLocationWhileUsingApp() {
162162 'android=new UiSelector().textMatches("(?i)while using the app|only this time|allow")' ,
163163 ] ) ;
164164}
165+
165166/**
166167 * Wait for the app to fully launch and the home screen to be visible.
167168 *
@@ -179,16 +180,20 @@ export async function waitForAppReady(opts: { skipLogin?: boolean } = {}) {
179180
180181 if ( skipLogin ) return ;
181182
182- // want to login user so we can't clean up/delete user data for the next rerun
183- const testUserId = getTestExternalId ( ) ;
184- const loggedIn = await browser . sharedStore . get ( 'loggedIn' ) ;
183+ // Want to login the user so we can clean up/delete its data on the next rerun.
184+ // `loggedIn` is module-local (worker-scoped) on purpose: each WDIO worker
185+ // runs in its own Node process and drives one device, so the cache reflects
186+ // that device's state. Sharing across workers (e.g. via sharedStore) would
187+ // lie when running parallels on BrowserStack.
188+ const loggedIn = browser . sharedStore . get ( 'loggedIn' ) ;
185189 if ( ! loggedIn ) {
190+ const testUserId = getTestExternalId ( ) ;
186191 const userIdEl = await scrollToEl ( 'user_external_id_value' , { direction : 'up' } ) ;
187192 const sessionUserId = await userIdEl . getText ( ) ;
188193 if ( sessionUserId !== testUserId ) {
189194 await loginUser ( testUserId ) ;
190195 }
191- await browser . sharedStore . set ( 'loggedIn' , true ) ;
196+ browser . sharedStore . set ( 'loggedIn' , true ) ;
192197 }
193198}
194199
Original file line number Diff line number Diff line change @@ -26,7 +26,6 @@ const bstackOptions = {
2626
2727export const sharedConfig : WebdriverIO . Config = {
2828 ...( isLocal ? localConnection : browserstackConnection ) ,
29-
3029 maxInstances : 1 ,
3130 logLevel : 'warn' ,
3231
@@ -62,8 +61,11 @@ export const sharedConfig: WebdriverIO.Config = {
6261 // BrowserStack-only: report final session status to the BrowserStack
6362 // dashboard. The `browserstack_executor:` script is unsupported by local
6463 // Appium drivers and would otherwise log "Method is not implemented".
64+ // We also no-op if the session never initialized (e.g. a queue-limit
65+ // rejection during session create) — `browser.executeScript` won't exist.
6566 after : async function ( result ) {
6667 if ( isLocal ) return ;
68+ if ( typeof browser ?. executeScript !== 'function' ) return ;
6769 const status = result === 0 ? 'passed' : 'failed' ;
6870 const reason = result === 0 ? 'All tests passed' : 'Test failures' ;
6971 await browser . executeScript (
You can’t perform that action at this time.
0 commit comments