@@ -7,7 +7,7 @@ const log = logger('@wdio/lambdatest-service')
77/** @type {import('./types.js').LTOptions & import('./types.js').SessionNameOptions } */
88const DEFAULT_OPTIONS = {
99 setSessionName : true ,
10- setSessionStatus : true
10+ setSessionStatus : true ,
1111} ;
1212
1313export default class LambdaRestService {
@@ -28,6 +28,7 @@ export default class LambdaRestService {
2828 _testTitle ;
2929 _error ;
3030 _ltErrorRemark ;
31+ _useScenarioName ;
3132 _lambdaCredentials ;
3233 _currentTestTitle ;
3334
@@ -70,21 +71,28 @@ export default class LambdaRestService {
7071 {
7172 this . _ltErrorRemark = true ;
7273 }
74+ // Cucumber specific option to set test name from scenario
75+ if ( this . _config . useScenarioName === true )
76+ {
77+ this . _useScenarioName = true ;
78+ }
7379
7480 this . _isServiceEnabled = lambdaCredentials . username && lambdaCredentials . accessKey ;
7581 this . _lambdaCredentials = lambdaCredentials ;
7682
7783 }
7884
7985 async beforeScenario ( world , context ) {
80- if ( ! this . _suiteTitle ) {
86+ if ( this . _useScenarioName ) {
87+ this . _testTitle = world ?. pickle ?. name || 'unknown scenario' ;
88+ } else if ( ! this . _suiteTitle ) {
8189 this . _suiteTitle =
8290 world ?. gherkinDocument ?. feature ?. name ||
8391 context ?. document ?. feature ?. name ||
8492 world ?. pickle ?. name ||
8593 'unknown scenario' ;
86- await this . setSessionName ( this . _suiteTitle ) ;
8794 }
95+ await this . setSessionName ( this . _testTitle || this . _suiteTitle ) ;
8896 }
8997
9098 async beforeSuite ( suite ) {
@@ -338,8 +346,7 @@ export default class LambdaRestService {
338346 if ( ! this . _options . setSessionName || ! suiteTitle ) {
339347 return ;
340348 }
341-
342- let name = suiteTitle ;
349+ let name = this . _useScenarioName && this . _testTitle ? this . _testTitle : suiteTitle ;
343350 if ( this . _options . sessionNameFormat ) {
344351 name = this . _options . sessionNameFormat (
345352 this . _config ,
0 commit comments