Invalid response from karate.read inside a js function
See original GitHub issueJava8 and karate 0.6.1 & 0.6.2
Given the test.json file content
{ "foo":"bar"}
When calling the following function from a feature file
function() {
var test = karate.read('classpath:api/test.json');
karate.log(test);
karate.log(JSON.stringify(test));
}
then the value of test is undefined
but if called in a feature like:
* def test = call('classpath:api/test.json')
* print test
then the value of test is the json structure
I have tried many combinations but it never reads the json correctly
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Invalid response from karate.read inside a js function #267
For context, I'm trying to make a more simple, readable way to call some helper functions, like * run_helper("create", "client") , but the...
Read more >Using call read within a js function - karate - Stack Overflow
So the idea is to reset the 'myId' variable everytime to null, check if null which will be true, then call the js...
Read more >Karate UI
A very powerful variation of waitUntil() takes a full-fledged JavaScript function as the argument. This can loop until any user-defined condition and can...
Read more >Step-2: Variables, karate-config, API requests, Assertions - Kloia
This is a simple JS function. You can define the variables in the config as a JSON format (“key: value” structure) and use...
Read more >Calling Custom Java Code in Karate API Tests
This code simply writes our token to config.properties file by using write method. Then you can read the value by using read method....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@justindwyer6 and most likely you are looking for
karate.call()
. I am still not sure what you are trying and whether a “feature type” works in JS - so we may still need that way to replicate@justindwyer6 can’t tell from this. follow this process please: https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue