0

I have been researching for a simple solution to a problem that I have.

I have a JavaScript file that needs to use some functions that are contained in another JS file. I read many posts from stack overflow, and they all require a to be loaded from a web page. In my case they absolutely do not use a web page to be loaded and I do not want to use one.

The reason is because I am running JavaScript unit testing from command line using Rhino. Please I'm begging for help!

2 Answers 2

1

You can load in the other javascript file using Ajax. Have a look at jQuery .getScript(). I'm not sure if that'll work in the context of running from the command line, or if it just appends the .js file to the document.body.

Sign up to request clarification or add additional context in comments.

2 Comments

There's more details about doing this in another Stack Overflow post here: stackoverflow.com/questions/950087/…
thank you very much for your answer, I already looked at that post @kah608, but the options used they all require a web browser, Thank you Duncan, by chance are you aware of any JavaScript Native commands? Will JQuery need a browser to be loaded though?
1

Use Rhino's load function (about a third of the way down this page): https://developer.mozilla.org/en/Rhino_Shell

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.