Ask a Question

Javascript Unit references - UseUnit or Modules.export?

Frequent Contributor

Javascript Unit references - UseUnit or Modules.export?

In JavaScript Project, For Reference of the units which methods is better to use either USEUNIT or Modules.Export. or Require.?


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.


thanks in advance


With Regards
Vallalarasu Pandiyan
Esteemed Contributor

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

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

I would personally use the modules.exports, it allows for better control of what functions other script units have access too.


Click the Accept as Solution button if my answer has helped
Showing results for 
Search instead for 
Did you mean: