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.

  1. Generic configurations: First, the config.yml is parsed for generic configuration settings, and specified configurations are set in Karate properties.

  2. 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:

    1. defaultUsername is set to userA in the config.yml file.

    2. defaultUsername is not set in config-local.yml file.

    3. defaultUsername is set to userB in the config-pre.yml file.

      When the test runs on local environment, the defaultUsername will be the default value userA. When the test runs on pre environment, the defaultUsername will be the defined userB.