When using JavaScript in a storeEval and it contains a <
or >
the browser will freeze and sometimes crash. It usually needs the be force closed.
Example:
storeEval | (()=>{ if(1 < 2) {return 'A'} else {return 'B'} })() | test
Currently the only workaround is the replace the characters with an escaped equivalent, make the JavaScript a string, unescape and eval. For example, this works but is annoying to do:
storeEval | eval(unescape("(()=>{ if(1 %3C 2) {return 'A'} else {return 'B'} })()")) | test
1 Like
Try it without the function declaration
| storeEval | if(1 < 2) {'A'} else {'B'} | test |
| echo | ${test} | |
Here’s the output I get
[info] Executing: | storeEval | if(1 < 2) {'A'} else {'B'} | test |
[info] Store 'A' into 'test'
[info] Executing: | echo | ${test} | |
[info] Expand variable '${test}' into 'A'
[info] echo: A
1 Like
That does appear to be a much better workaround than mine. However, the lack of return statements makes it more difficult to read and when you do have a return statement it complains about Illegal return statement
and won’t run.
I am still curious though because it is valid JavaScript, it should work. What is it about the module pattern ((arg)=>{ return 'result'})(value)
that causes the Katalon eval to break on <
and >
? I would prefer to write it in module pattern so that I could have clear return calls.
Edit: While testing some more it appears to be the arrow function declaration that causes it (()=>{})()
while the traditional (function() {})()
seems to work fine with <
and >
.
Broken:
storeEval | (()=>{ if(1 < 2) {return 'A'} else {return 'B'} })() | test
Works:
storeEval | (function() { if(1 < 2) {return 'A'} else {return 'B'} })() | test
1 Like