In Karate, you can set certain framework settings via the configure keyword, such as
* configure httpTimeout = 5000
* configure ssl = true
* eval karate.configure('readTimeout',10000);
But how can you see the values of these settings? Can you determine the defaults? What if you need to temporarily override them for part of a test and restore the previous value afterwards?
The
karate.configure()method and theconfigurekeyword relate back to a singleton object called ScenarioEngine. You can access this object from thekarateobject from within Javascript interop, via thegetEngine()method, which in turn has agetConfig()method to access getters and setters for these values.which will print:
showing the original default of 30000, and confirming the updated value of 12345. (This will work the exact same way using the
configurekeyword.)You can use JS's Object.keys() to see all the available getter and setter methods for config values on the object returned by
.config().