karate-config.js / karate-config-<env>.js
Karate first will look for karate-config.js and it will process it.
If the karate.env property is set and the over-ride karate-config-<env>.js exists, it will be processed, and the configuration returned by this function will over-ride any set by karate-config.js
config.yml / config-<env>.yml
It is very important to understand the working principle of the config.yml and config-<env>.yml files since they work in a cumulative fashion.
-
Generic configurations: First, the
config.ymlis parsed for generic configuration settings, and specified configurations are set in Karate properties. -
Specific configurations: Then the environment-specific file is parsed, and specified values are set in Karate properties. So, if the same property exists in both files, then environment-specific values will overwrite the generic ones. For example:
-
defaultUsernameis set touserAin theconfig.ymlfile. -
defaultUsernameis not set inconfig-local.ymlfile. -
defaultUsernameis set touserBin theconfig-pre.ymlfile.When the test runs on
localenvironment, thedefaultUsernamewill be the default valueuserA. When the test runs onpreenvironment, thedefaultUsernamewill be the defineduserB.
-