How to use karate.callSingle() in my karate-config.js?

青春壹個敷衍的年華 提交于 2019-12-24 17:16:35

问题


The following is my karate-config.js file. The classpath for the feature that i want to call only once is classpath:com/test/scenario/accessToken.feature . where should i include the karate.callSingle()

function init() {
    karate.log('Env set to ', karate.env);
    karate.log('baseURL ', karate.properties['baseURL']);
    karate.log('OriginURl',karate.properties['OriginURL'])


    return {
        env: karate.env,

        SECRET: karate.properties['clientSecret'],
        TOKEN: {
            "CSRF": "",
            'ACCESS': ""
        },



        }
    };
}

回答1:


You can include it anywhere, before you return the JSON. I suggest you take the help of someone who knows basic JavaScript near you, please. It is clearly mentioned in the documentation that this is for advanced users. If you have not understood my answer to your previous question, I have nothing more to add: https://stackoverflow.com/a/51288570/143475

But let me try again. On line 13 you can do:

var result = karate.callSingle('classpath:com/freshworks/freshid/test/scenario/accessToken.feature');

And then on line 20 (this totally depends on how you have written accessToken.feature, I can't believe I am still trying to help you)

TOKEN: {
  CSRF: result.csrf,
  ACCESS: result.access
}


来源:https://stackoverflow.com/questions/51399404/how-to-use-karate-callsingle-in-my-karate-config-js

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!