【问题标题】:Is there a way to just get a list of all the specs in a suite in a jasmine report?有没有办法在茉莉花报告中获取套件中所有规格的列表?
【发布时间】:2016-09-12 15:40:13
【问题描述】:

我需要量角器配置文件中套件中提到的所有规范的列表,并知道可能失败的原因。有没有办法做到这一点?我正在为此编写自定义茉莉花报告。

谢谢!

【问题讨论】:

    标签: jasmine protractor jasmine-reporters


    【解决方案1】:

    您将在自定义 jasmine 报告器中使用类似的内容:

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

    【讨论】:

      猜你喜欢
      • 2017-02-10
      • 1970-01-01
      • 2016-02-17
      • 2020-05-07
      • 1970-01-01
      • 1970-01-01
      • 2023-04-02
      • 2015-05-05
      • 2014-04-11
      相关资源
      最近更新 更多