1

For example i do

* def fooresponse = call read('../getfooid.feature')

* def jsfunction= """(fooresponse){ console.log(fooresponse)}"""

is that possible? what is the recommended way to do it?

Thanks!

edit: fixing js syntax lol

1
  • also as a follow up question, is it possible to give values to a karate.call()just like we do it with call read Commented Jan 4, 2018 at 16:26

1 Answer 1

2

Yes, this will work if the function has been defined after the variable fooresponse:

* def jsfunction = function(){ karate.log(fooresponse) }

Yes, you can pass a single argument to karate.call().

Keep in mind that the #(foo) substitution does NOT apply to pure-JS, explained here: https://github.com/intuit/karate#karate-expressions

I think once you read the above link AND if you are familiar with JS, you will know what to do.

Like this:

* def fun = function(){ karate.call('foo.feature', { bar: 'baz' }) }
Sign up to request clarification or add additional context in comments.

2 Comments

what i mean was with call read(../something.feature) we can pass in arguments like so {id : '#(response.id)'}, i was wondering if i can use the same curly braces style with a js function. i went through the following documentation github.com/intuit/karate/blob/master/karate-demo/src/test/java/… but it doesnt really show an example of passing values like we do in a call read
thank you though it works. i will read the documentation more and more

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.