1

karate-config.js provides handy way to create global variables, like in this Karate doc example

config.someUrlBase = 'https://e2e-host/v1/auth';

But for our test, we'd rather don't modify karate-config.js, so can we do the same (that is create global variables) for instance in our headers.js file?

We tried, in headers.js: (a) config.myvariabe= (b) karate.set in headers.js and then karate.get in .feature

Paul G
  • 41
  • 2

1 Answers1

0

My recommendation is don't over-complicate things. Just have a bunch of extra variables in karate-config.js and use those.

Yes, in theory you can call karate.set() anywhere, and after that use that variable in a *.feature. If that does not work, follow this process: https://github.com/karatelabs/karate/wiki/How-to-Submit-an-Issue

Also please be aware of this: https://stackoverflow.com/a/46080568/143475

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248