Javascript Unit references - UseUnit or Modules.export?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Javascript Unit references - UseUnit or Modules.export?
Please point out the advantages and drawbacks of each methods.
Also, Will //USEUNIT get depreceated in future for JavaScript alone, As it is mentioned as Legacy support.
https://support.smartbear.com/testcomplete/docs/scripting/calling-routines/declared-in-another-unit/...
thanks in advance
Valla
Vallalarasu Pandiyan
https://www.linkedin.com/in/vallalarasupandiyan/
- Labels:
-
Scripting
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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/...
Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----
Why automate? I do automated testing because there's only so much a human being can do and remain healthy. Sleep is a requirement. So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.
Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I would personally use the modules.exports, it allows for better control of what functions other script units have access too.
Thanks,
Carson
Click the Accept as Solution button if my answer has helped
