Is there a functionality to combine karate-config.js files from multiple projects into a single file in karate?

853 Views Asked by At

We have two projects with the structure test -> project1 -> karate-config.js and test ->project2 ->karate-config.js. Ideally i would like to combine the configs into a single config file at the test folder level like test ->karate-config.js ( project1 + project2). Both projects use a similar structure in the config file except for the the API endpoint URL's. Thanks in Advance !

1

There are 1 best solutions below

0
On BEST ANSWER

You can read any JS function at any time and evaluate it. If it returns a JSON, you can use karate.merge() to add it to the config. So that gives you many possibilities.

var fun = read('classpath:some.js');
config = karate.merge(config, fun());

That said please be aware that there is a concept of karate-base.js - so please read the docs: https://github.com/intuit/karate#karate-basejs