Forum Discussion

MadhuLambu's avatar
MadhuLambu
Occasional Contributor
4 months ago
Solved

Problem with using arrow functions

Dear community, am having bit of an issue using arrow function defined in another file. Code snippet is below.  Looking forward to any hints.

Test1.JS
-------------
const str = 'xyz';
const getStr = () => str;

Test2.JS
-------------
//USEUNIT Test1
function test() {
  Log.Message(Test1.getStr());
}

I get an error at the statement where Test1.getStr() is called.
  JavaScript runtime error.
  TypeError: Test1.getStr is not a function

If I modify Test1.JS to the below lines, it then starts working.
const str = 'xyz';
getStr = () => str;  //notice that I have removed const

Any idea what am missing? Did I hit a limitation in TestComplete?  BTW, if the arrow function and the caller are in the same JS file, it works with no issues.

Best Regards,
Madhu

 

3 Replies