automationautomated-testscucumberkaratecucumber-java

How to configure karate-config.js and read values from it


I am trying to setup karate-config.js file in our project as shown in the below. enter image description here

I have configured some test script in that file.

function fun(){
    
    var config = {
            host : "http://172.25.0.1:61047/abc"
    };
    
    return config;
}

Calling host from below scenario

Scenario: Generate Token POST
    Given print 'host --------------->>>>>', host

Output is getting nothing. enter image description here

Anyone please help me here, what I made the mistake in the code.


Solution

  • I finally fixed this issue, i just moved the karate-config.js file from src/test/java to src/test/resource.

    Now karate-config.js file has been loading and I am able to read data from it.