4

How to debug vows test?

I was thinking to make an html reporter for the tests and run tests in the browser, but I really don't know how and where to start.

If there are better workarounds I'm happy to hear, thanks ;) code from my reporter

this.print = function (str) {
    util.print(str);
};


function removeCircularSuite(obj, suite) {
    var result = {};

    if (typeof obj !== 'object' || obj === null) return obj;

    Object.keys(obj).forEach(function(key) {
        if (obj[key] === suite) {
            result[key] = {};
        } else {
            result[key] = removeCircularSuite(obj[key], suite || obj.suite);
        }
    });

    return result;
};

this.report = function (obj) {
    this.i++;
    console2.log(this.i);
    puts(JSON.stringify(removeCircularSuite(obj)));
};

but this is ran twice so the output it's:

1
1
{"0":"subject","1":"insert worker"}
2
{"0":"subject","1":"insert worker"}
{"0":"context","1":"insertWorker"}
2
{"0":"context","1":"insertWorker"}
3
{"0":"vow","1":{"title":"find worker in the database","context":"insertWorker","status":"broken","exception":"\u001b[33mfound multiple records with the same _id\u001b[39m\u001b[90m // services.insertWorker.test.js:25\u001b[39m"}}
3
{"0":"vow","1":{"title":"find worker in the database","context":"insertWorker","status":"broken","exception":"\u001b[33mfound multiple records with the same _id\u001b[39m\u001b[90m // services.insertWorker.test.js:25\u001b[39m"}}
4
{"0":"end"}
5
4
{"0":"finish","1":{"honored":0,"broken":1,"errored":0,"pending":0,"total":1,"time":0.005}}
{"0":"end"}
5
{"0":"finish","1":{"honored":0,"broken":1,"errored":0,"pending":0,"total":1,"time":0.005}}
4

0 回答 0