@@ -179,17 +179,22 @@ export async function waitForAppReady(opts: { skipLogin?: boolean } = {}) {
179179
180180 if ( skipLogin ) return ;
181181
182- // want to login user so we can't clean up/delete user data for the next rerun
182+ // Want to login the user so we can clean up/delete its data on the next rerun.
183+ // The sharedStore cache is a local-only optimization: locally we reuse the same
184+ // emulator/simulator across specs, so once we've logged in we can skip the
185+ // text-check on subsequent specs. On BrowserStack each parallel session lands
186+ // on a fresh device, so the flag would lie about another session's state.
183187 const testUserId = getTestExternalId ( ) ;
184- const loggedIn = await browser . sharedStore . get ( 'loggedIn' ) ;
185- if ( ! loggedIn ) {
186- const userIdEl = await scrollToEl ( 'user_external_id_value' , { direction : 'up' } ) ;
187- const sessionUserId = await userIdEl . getText ( ) ;
188- if ( sessionUserId !== testUserId ) {
189- await loginUser ( testUserId ) ;
190- }
191- await browser . sharedStore . set ( 'loggedIn' , true ) ;
188+ const isLocal = ! process . env . BROWSERSTACK_USERNAME ;
189+
190+ if ( isLocal && ( await browser . sharedStore . get ( 'loggedIn' ) ) ) return ;
191+
192+ const userIdEl = await scrollToEl ( 'user_external_id_value' , { direction : 'up' } ) ;
193+ const sessionUserId = await userIdEl . getText ( ) ;
194+ if ( sessionUserId !== testUserId ) {
195+ await loginUser ( testUserId ) ;
192196 }
197+ if ( isLocal ) await browser . sharedStore . set ( 'loggedIn' , true ) ;
193198}
194199
195200/**
0 commit comments