-1

Make a new feature file test.feature as below

Feature: Test bug

  @first
  Scenario: Test first
    * getValue()
    * karate.call('test.feature@second')

  @second
  Scenario: Test Second
    * getValue()

Now go to karate-config.js and make below function

function getValue() {
    karate.log('hello');
    karate.log('excuted this function')
}

Now run your first scenario by right click on scenario, you will see that the function is getting recognized by 1st scenario but not getting recognized by second scenario

Vishal Rathore
  • 137
  • 1
  • 13

1 Answers1

1

I suppose you are calling karate.call('myFeature.feature@newCheck') inside karate-config.js right after you have defined our myJsMethodCall() as config.myJsMethodCall ?

If so, you have to pass config as the second parameter so that myJsMethodCall() will be available in the scope of the called feature

karate.call('myFeature.feature@newCheck', config)

Note: variables declared in karate-config.js will be available to the features only after completion of it evaluation.

Babu Sekaran
  • 4,129
  • 1
  • 9
  • 20