简体   繁体   English

在 karate-config.js 中定义另外两个函数

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

My karate-config.js is:我的 karate-config.js 是:

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

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

That was working fine until I upgraded my Java version to 17.在我将 Java 版本升级到 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另请参阅: https://github.com/karatelabs/karate#multiple-functions-in-one-file

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将Json传递给karate-config.js文件 - Pass Json to karate-config.js file Karate-config.js 文件未在 eclipse 中保存为 JS 文件 - Karate-config.js file is not saved as JS file in eclipse 空手道 - karate.configure('headers', { Accept: 'application/json' }); 在 karate-config.js 文件中无法识别。 它说缺少导入语句 - Karate - karate.configure('headers', { Accept: 'application/json' }); is not recognized in karate-config.js file. It says missing import statements Karate-config.js - 是否有可能在其他地方使用 java class 的方法? - Karate-config.js - is it possible to have methods of a java class made available for use elsewhere? 如何在next.config.js中添加两个以上的插件 - How to add more than two plugins in a next.config.js 由以下原因引起:com.intuit.karate.exception.KarateException:ReferenceError:空手道配置js文件中未定义“ XMLHttpRequest”异常 - Caused by: com.intuit.karate.exception.KarateException: ReferenceError: “XMLHttpRequest” is not defined Exception in Karate config js file JS中定义函数/方法之间的区别? - differences between defining functions/methods in JS? 在两个或多个功能之间切换 - Toggle between two or more functions 在JavaScript中添加两个或多个函数 - Addition of two or more functions in javascript 结合两个JS函数 - Combine two JS functions
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM