Integración de ZombieJS y Qunit

has anyone integrated QUnit tests with ZombieJS? I have a script so i want to pass a "tests.html" file and poll until the tests complete, then read the results. Similar to what i'm doing with PhantomJS and it works perfectly fine. I'd mostly like to compare Phantom and Zombie with respect to performance. Also we have a lot of Qunit tests already created so i don't want to just dump them and rewrite everything from scratch in the Zombie environment (if i decide to go for it in the first place :)

the issue i am facing is that my tests never complete, so Qunit is always in running state. Haven't debugged anything in detail yet, but just wanted to make sure i am not missing something obvious.

var Browser = require("zombie");
var assert = require("assert");

// Load the page from localhost
browser = new Browser();

function waitFor(testFx, onReady, timeOutMillis) {
    var maxtimeOutMillis = timeOutMillis ? timeOutMillis : 100000, //< Default Max Timout is 3s
        start = new Date().getTime(),
        condition = false,
        interval = setInterval(function() {
            if ( (new Date().getTime() - start < maxtimeOutMillis) && !condition ) {
                // If not time-out yet and condition not yet fulfilled
                condition = (typeof(testFx) === "string" ? eval(testFx) : testFx()); //< defensive code
            } else {
                if(!condition) {
                    // If condition still not fulfilled (timeout but condition is 'false')
                    console.log("'waitFor()' timeout");
                } else {
                    // Condition fulfilled (timeout and/or condition is 'true')
                    console.log("'waitFor()' finished in " + (new Date().getTime() - start) + "ms.");
                    typeof(onReady) === "string" ? eval(onReady) : onReady(); //< Do what it's supposed to do once the condition is fulfilled
                    clearInterval(interval); //< Stop this interval
        }, 100); //< repeat check every 250ms

browser.visit("tests.html", function () {

            return browser.evaluate(function(){
                var el = browser.document.getElementById('qunit-testresult');
                if (el && el.textContent.match('completed')) {
                    return true;
                return false;
        }, function(){
            var failedNum = browser.evaluate(function(){
                var el = browser.document.getElementById('qunit-testresult');
                try {
                    return el.getElementsByClassName('failed')[0].innerHTML;
                } catch (e) { }
                return 10000;
            process.exit((parseInt(failedNum, 10) > 0) ? 1 : 0);

preguntado el 04 de julio de 12 a las 08:07

Have you ever gotten your code to work? I was trying to achieve the same thing but was at a much earlier stage than you and am very interested in your piece of code (I've just raised a Q as I missed yours:…). -

0 Respuestas

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.