4

誓いのテストをデバッグするには?

テスト用の html レポーターを作成し、ブラウザーでテストを実行することを考えていましたが、どのように、どこから始めればよいか本当にわかりません。

より良い回避策があれば、喜んで聞いてくれます、ありがとう ;) レポーターからのコード

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)));
};

しかし、これは2回実行されるため、出力は次のようになります。

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