茉莉花 - 记者没有生成任何文件

Lia*_*nat 1 jasmine jasmine-node protractor

我正在使用茉莉花 - 记者在量角器完成测试后生成报告,

这是我的配置文件:

  onPrepare: function(){
            var jasmineReporters = require('jasmine-reporters');
            var capsPromise = browser.getCapabilities();
            capsPromise.then(function(caps){
                var browserName = caps.caps_.browserName.toUpperCase();
                var browserVersion = caps.caps_.version;
                var prePendStr = browserName + "-" + browserVersion + "-";
                jasmine.getEnv().addReporter(new jasmineReporters.JUnitXmlReporter("protractor_output", true, true,prePendStr));
            });
     },
Run Code Online (Sandbox Code Playgroud)

我没有得到任何错误,记者安装,但我没有在protractor_output文件夹中看到任何文件.

知道我做错了什么吗?

Lia*_*nat 7

问题出在jamsine版本:

如果你想在Protractor中使用jasmine-reporter,请记住Protractor是围绕Jasmine 1.x构建的.因此,您需要使用1.x版本的茉莉花 - 记者.

npm install jasmine-reporters@~1.0.0
Run Code Online (Sandbox Code Playgroud)

那么配置应该是:

onPrepare: function() {
    // The require statement must be down here, since jasmine-reporters@1.0
    // needs jasmine to be in the global and protractor does not guarantee
    // this until inside the onPrepare function.
    require('jasmine-reporters');
    jasmine.getEnv().addReporter(
        new jasmine.JUnitXmlReporter('xmloutput', true, true)
    );
}
Run Code Online (Sandbox Code Playgroud)

如果您使用的是较新版本的Jasmine Reporter,则该require语句不再JUnitXmlReporter将该jasmine对象置于对象上,而是将其置于模块导出中.您的设置将如下所示:

onPrepare: function() {
    // The require statement must be down here, since jasmine-reporters@1.0
    // needs jasmine to be in the global and protractor does not guarantee
    // this until inside the onPrepare function.
    var jasmineReporters = require('jasmine-reporters');
    jasmine.getEnv().addReporter(
        new jasmineReporters.JUnitXmlReporter('xmloutput', true, true)
    );
}
Run Code Online (Sandbox Code Playgroud)

您还需要验证xmloutput目录是否存在!