Karate config
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.yml
is 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:
-
defaultUsername
is set touserA
in theconfig.yml
file. -
defaultUsername
is not set inconfig-local.yml
file. -
defaultUsername
is set touserB
in theconfig-pre.yml
file.When the test runs on
local
environment, thedefaultUsername
will be the default valueuserA
. When the test runs onpre
environment, thedefaultUsername
will be the defineduserB
.
-