[SOLVED] Defining two o more functions in karate-config.js


My karate-config.js is:

function config(){
    return karate.read('classpath:' + env_file());

function env_file(){
    var env_file = karate.env;
        env_file = 'local.yml';
    return 'env/' + env_file;

That was working fine until I upgraded my Java version to 17.

Now I’m getting the following exception:

org.graalvm.polyglot.PolyglotException: SyntaxError: Unnamed:5:0 Expected ) but found function

Is it possible now to define two functions in the same file?

Thanks in advance.


No. It was never supposed to have been supported, I’m surprised it worked.

Also refer: https://github.com/karatelabs/karate#multiple-functions-in-one-file

Answered By – Peter Thomas

Answer Checked By – Clifford M. (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *