有没有办法在茉莉花报告中获得套件中所有规格的列表?

时间:2016-09-12 15:40:14

标签: jasmine protractor jasmine-reporters

我需要一个从量角器配置文件中提到的套件中提到的所有规格的列表,并知道可能失败了。有没有办法实现这个目标?我正在为此写一份自定义茉莉花报告。

谢谢!

1 个答案:

答案 0 :(得分:0)

您将在自定义茉莉花记者中使用类似的内容:

var suiteResults = [];
var currentSpecName;
var currentSpecStatus;

specStarted: function(spec) {
    // get the name of the spec
    console.log('Starting Spec: ' + spec.fullName);
    currentSpecName = spec.fullName;
};

specDone: function(result) {
    var passCount = result.passedExpectations.length;
    var failCount = result.failedExpectations.length;
    var expectationCount = passCount + failCount;

    var specIsDisabled = result.status === 'disabled';
    var specIsPending = result.status === 'pending';
    var specIsInvalid = !specIsDisabled && !specIsPending && expectationCount === 0;
    var specPassed = !specIsDisabled && !specIsPending && !specIsInvalid && failCount === 0;
    var specFailed = !specIsDisabled && !specIsPending && !specIsInvalid && !specPassed;    

    currentSpecStatus = specFailed ? 'FAILED' : 'PASSED';
    console.log('Status: ' + currentSpecStatus);
    suiteResults.push({specName: currentSpecName, specStatus: currentSpecStatus});
};

suiteDone: function() {
    var specCount = suiteResults.length;
    var failCount = suiteResults.filter(function(result) {
        return result.specStatus === 'FAILED';
    }).length;
    console.log(specCount + ' specs, ' + failCount + ' failures');
},