本文介绍了如何在我的karate-config.js中使用karate.callSingle()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是我的karate-config.js文件.我只想调用一次的功能的类路径是classpath:com/test/scenario/accessToken.feature.我应该在哪里包括karate.callSingle()

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': ""
        },



        }
    };
}

推荐答案

您可以在返回JSON之前将其包括在任何位置.我建议您请附近有一些基本JavaScript的人帮忙.文档中明确提到这是针对高级用户的.如果您不了解我对上一个问题的回答,那么我无添加: https://stackoverflow.com/a/51288570 /143475

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

但是让我再试一次.在第13行,您可以执行以下操作:

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

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

然后在第20行(这完全取决于您如何编写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
}

这篇关于如何在我的karate-config.js中使用karate.callSingle()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-16 07:03