Reputation: 139
I am using an authorization token in all my feature files . To generate the authorization token i need to call a particular feature file(token.feature) . Since I am using the token in all features I keep calling the same feature file again and again. The solution i found is the use of karate.callSingle() in karate-config.js but i dont know how to use karate.callSingle().
Upvotes: 1
Views: 7554
Reputation: 58058
In karate-config.js
you can do this:
var config = { myprop: 'myvalue', myurl: 'somevalue' };
var result = karate.callSingle('classpath:token.feature', config);
config.token = result.token; // assuming you did 'def token'
return config;
Now all your features can use the variable token
.
This is explained in the docs: https://github.com/intuit/karate#hooks
Upvotes: 3