skip to content

testing mootools apps using rhino shell

As the guys from Mozilla say “The JavaScript shell provides a simple way to run scripts in batch mode or an interactive environment for exploratory programming.”

So basically you can create some tests for you app based on javascript without needing a browser, but using rhino.
With Mootools is a little complicated, as it needs a browser environment to run, and rhino does not provide this.
The solution for this is to simulate a browser.

A great work in this direction is made by John Resig, the guy behind jQuery, here. Only that you will need to modify a little the script, to work with Mootools.

Add the following lines at the very end of the env.js script

 
var document =  window.document;
window.Element = window.DOMElement;
window.navigator.platform = "MacPPC";

window.navigator.platform can be any platform, I used this to reflect my own platform.

 

One Response

11.11.2010

Hi,

It’s been some time now since you posted that. I’m trying to integrate full support for server side testing through mootools-runner. After failing with the standard node.js runner and jsdom, I’m now giving a try to rhino + env.js.

Things seem to be a bit more complicated with the current state of env.js than when you wrote this post.

So my question is : are you still using rhino + env.js with mootools?


Switch to our mobile site