@@ -9,6 +9,7 @@ const log = logger('@wdio/lambdatest-service')
99const DEFAULT_OPTIONS = {
1010 setSessionName : true ,
1111 setSessionStatus : true ,
12+ ignoreTestCountInName :false ,
1213} ;
1314
1415export default class LambdaRestService {
@@ -18,6 +19,7 @@ export default class LambdaRestService {
1819 _config ;
1920 _failReasons = [ ] ;
2021 _failures = 0 ;
22+ _retryFailures = 0 ;
2123 _failureStatuses = [ 'failed' , 'ambiguous' , 'undefined' , 'unknown' ] ;
2224 _fullTitle ;
2325 _isServiceEnabled = true ;
@@ -159,11 +161,13 @@ export default class LambdaRestService {
159161
160162 afterTest ( test , context , { error, passed } ) {
161163 this . _specsRan = true ;
164+ this . _fullTitle = this . _currentTestTitle
162165
163166 // remove failure if test was retried and passed
164167 // (Mocha only)
165168 if ( test . _retriedTest && passed ) {
166169 -- this . _failures ;
170+ this . _retryFailures = 0 ;
167171 return ;
168172 }
169173
@@ -178,12 +182,14 @@ export default class LambdaRestService {
178182 test . _currentRetry < test . _retries
179183 )
180184 ) {
185+ ++ this . _retryFailures ;
181186 return ;
182187 }
183188
184189 const isJasminePendingError = typeof error === 'string' && error . includes ( 'marked Pending' ) ;
185190 if ( ! passed && ! isJasminePendingError ) {
186191 ++ this . _failures ;
192+ ++ this . _retryFailures ;
187193 this . _failReasons . push ( ( error && error . message ) || 'Unknown Error' )
188194 this . _error = error ?. message || 'Unknown Error' ;
189195 if ( this . _ltErrorRemark && this . _error !== null && this . _error !== undefined ) {
@@ -270,7 +276,7 @@ export default class LambdaRestService {
270276 return ;
271277 }
272278
273- const status = ( this . _failures > 0 ? 'failed' : 'passed' ) ;
279+ const status = ( this . _failures > 0 || this . _retryFailures > 0 ) ? 'failed' : 'passed' ;
274280
275281 if ( ! this . _browser . isMultiremote ) {
276282 log . info ( `Update (reloaded) job with sessionId ${ oldSessionId } , ${ status } ` ) ;
@@ -317,16 +323,20 @@ export default class LambdaRestService {
317323
318324 async updateJob ( { sessionId, fullTitle, status, _failures, calledOnReload = false , browserName } ) {
319325
320- let body = this . getBody ( { _failures , calledOnReload , browserName } ) ;
326+ let body ;
321327 if ( calledOnReload ) {
322328 body = this . getBody ( { fullTitle, status, calledOnReload, browserName } ) ;
323329 }
330+ else {
331+ body = this . getBody ( { _failures, calledOnReload, browserName } ) ;
332+ }
324333 try {
325334 await updateSessionById ( sessionId , body , this . _lambdaCredentials ) ;
326335 } catch ( ex ) {
327336 console . log ( ex ) ;
328337 }
329338 this . _failures = 0 ;
339+ this . _retryFailures = 0 ;
330340 }
331341
332342 getBody ( { fullTitle, status, _failures, calledOnReload = false , browserName } ) {
@@ -357,8 +367,7 @@ export default class LambdaRestService {
357367 if ( this . _browser . isMultiremote ) {
358368 testCnt = Math . ceil ( testCnt / this . _browser . instances . length ) ;
359369 }
360-
361- if ( ! calledOnReload ) {
370+ if ( ! calledOnReload && ! this . _options . ignoreTestCountInName ) {
362371 body . name += ` (${ testCnt } )` ;
363372 }
364373 }
@@ -406,7 +415,7 @@ export default class LambdaRestService {
406415 } ;
407416
408417 const errorCustom = `lambda-hook: ${ JSON . stringify ( hookObject ) } ` ;
409- await this . _browser . execute ( errorCustom ) ;
418+ await this . _browser . executeScript ( errorCustom . toString ( ) , [ ] ) ;
410419 } catch ( error ) {
411420 console . log ( "Error setting session remarks:" , error ) ;
412421 }
0 commit comments