Forum Discussion
Starting with your last question first.
"Legacy" support refers to the need for supporting USEUNIT for any projects converted from JScript to JavaScript. JScript does not support the modules.export/require in TestComplete so any code units written in JScript use //USEUNIT. In converting, that needs to be supported so as to maintain a compatability.
As for which is better.... I think, personally, the native JavaScript Modules.Export/Require is preferred. It uses more of the main engine and doesn't rely on TestComplete specifics. You could easily write JavaScript code in some other IDE and then use it in TestComplete if necessary using that methodology and vice-versa (with caveats, of course, for any TestComplete specific objects and methods).
However... neither one is listed as "preferred". There are limitations and things that are different, all documented at https://support.smartbear.com/testcomplete/docs/scripting/calling-routines/declared-in-another-unit/javascript.html#useunit
I would personally use the modules.exports, it allows for better control of what functions other script units have access too.
Related Content
- 2 months ago
- 2 years ago