2

I've got a project that I'd like to move the testing from rhino to nodejs for (rhino simply takes too long to start and load in envjs). This is the current blocker before being able to move forward:

ExampleSingleton = new function () {
    var something = someFunction () {/*Does something*/}
    $(window).bind('resize', something);
}();

This complains about window not being defined - I don't know how to get the 'window' that I made in the shell (#!/usr/bin/env node) script that I wrote (see below, and pardon the chaos, as I've gotten to that "try anything and everything" point).

var dom = require("jsdom").jsdom()
var window = global.window = dom.createWindow();
global.jQuery = require("jQuery");
global.$ = global.jQuery;
....
require("path/to/file"); //This is where it breaks, before the tests even start

I've tried reading in and eval'ing as well, but that didn't much help and of course the error was masked because it was an anonymous function.

Am I trying to do the impossible here? Or is there a very simple browser friendly thing I can do to get this working?

1 Answer 1

2

Have you thought about using PhantomJS instead of node?

PhantomJS is a headless WebKit with JavaScript API. It has fast and native support for various web standards: DOM handling, CSS selector, JSON, Canvas, and SVG.

PhantomJS is an optimal solution for fast headless testing, site scraping, pages capture, SVG renderer, network monitoring and many other use cases.

Because it is a real browser, you won't need jsdom or envjs. JavaScript continuous testing with QUnit, PhantomJS and Powershell might help you get started.

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

1 Comment

Well, actually we ended up going that direction anyway. I'm going to give you the checkbox because it's pretty much exactly what we did :)

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.