cancel
Showing results for 
Search instead for 
Did you mean: 

import nodejs modules

SOLVED
Highlighted
Contributor

import nodejs modules

Hi

I've written a very basic login module in node.js, which works fine, but I need the following base modules enclosed:

var exec = require('child_process').exec;
var stream = require('stream');

is this possible, there is nothing about importing modules in

https://support.smartbear.com/testcomplete/docs/scripting/specifics/javascript.html 

 

testComplete give me this:

Error: Unable to find the specified module

Thanks

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Community Hero

Re: import nodejs modules

I repeat:

 

TestComplete does not use nodejs.  To do what you want to do, you need to 

 

1) Include the explicit code units into the TestComplete project

 

or

 

2) Create some sort of class library (.NET, Java, etc) that you can bring in using JavaBridge or CLR bridge to call that code.

 

https://support.smartbear.com/testcomplete/docs/testing-with/advanced/using-external-functions/calli...

 


Robert Martin
[Community Expert Group]
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

View solution in original post

4 REPLIES 4
Highlighted
Community Hero

Re: import nodejs modules

TestComplete is not the same type of environment as a regular IDE.  If you want to include external JavaScript code into TestComplete, you need to bring the units into TestComplete itself.  It doesn't consume nodejs like a web browser would normally.

 

So "child_process" and "stream" are JS modules that you would need to add to the TestComplete project via the Add -> Existing Item dialogs.


Robert Martin
[Community Expert Group]
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
Highlighted
Contributor

Re: import nodejs modules

Thanks for the reply,

I think this is impossible because they are native on node.js and links in lots of other requirements

https://github.com/nodejs/node/blob/master/lib/child_process.js

https://github.com/nodejs/node/blob/master/lib/stream.js

 

I can run it via wsShell, but would like to use nodejs toget finegrained interrupts and pipes etc

 

function RunTest(commandStr) {
var wsShell = Sys.OleObject("WScript.Shell");
wsShell.CurrentDirectory = Project.Variables.TestWorkingDirectory;
try {
wsShell.Exec(commandStr);
}
catch (ex) {
Log.Error("Command '" + commandStr + "' failed with:" + ex.description);
}
}

 

 

Community Hero

Re: import nodejs modules

I repeat:

 

TestComplete does not use nodejs.  To do what you want to do, you need to 

 

1) Include the explicit code units into the TestComplete project

 

or

 

2) Create some sort of class library (.NET, Java, etc) that you can bring in using JavaBridge or CLR bridge to call that code.

 

https://support.smartbear.com/testcomplete/docs/testing-with/advanced/using-external-functions/calli...

 


Robert Martin
[Community Expert Group]
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

View solution in original post

Highlighted
Community Manager

Re: import nodejs modules

Thank you tristaanogre!

 

@mortenb123 did you get a chance to try the suggested approaches? Please share the resultsSmiley Happy


Sonya Mihaljova
Community and Education Specialist

 Join the virtual SmartBear Connect user conference on April 27-28! Get your free virtual ticket today!