1

Hey so i have a javascript function in a separate file.

function polling_orderitem_CNCL(source_id, condition) {
    var i = 0;
    while (i < 10) {
        var result = karate.call('./polling/get_order_item.feature', {SourceId : source_id});
        var sCode = result.response.data.attributes.statusCode;
        karate.log('poll response', greeting);
        if (greeting == condition) {
            karate.log('condition satisfied, exiting');
            return;
        }
        karate.log('sleeping');
        java.lang.Thread.sleep(1000);
        i++;
    }
}

And im calling it in my feature file like so

* def waitUntil_CNCL = read('./polling/polling_orderitem_CNCL.js')
* call waitUntil_CNCL(ciSourceId, 'CNCL')

While running it i get the following error

[ERROR] Scenario: Get order and orderitem and verifications  Time
elapsed: 0.003 s  <<< ERROR
java.lang.RuntimeException: javascript evaluation failed: 'CNCL')
Caused by: javax.script.ScriptException:
<eval>:1:6 Expected ; but found )
'CNCL')
2

1 Answer 1

3

Please read the docs. Instead of using call you can "invoke" a function just like in "normal" JS: https://github.com/intuit/karate#js-function-argument-rules-for-call

Try this:

* eval waitUntil_CNCL(ciSourceId, 'CNCL')
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.