jasmine-reporters is not generating any file

余生颓废 提交于 2019-12-08 04:15:56

问题


i'm using jasmine-reporters to generate a report after protractor finish the tests,

this is my configuration file:

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

i don't get any error, the reporters installed, but i don't see any file in protractor_output folder.

Any idea what am i doing wrong?


回答1:


The problem is with the jamsine version:

If you are trying to use jasmine-reporters with Protractor, keep in mind that Protractor is built around Jasmine 1.x. As such, you need to use a 1.x version of jasmine-reporters.

npm install jasmine-reporters@~1.0.0

then the configuration should be:

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

If you are on a newer version of the Jasmine Reporter, then the require statement no longer puts the JUnitXmlReporter on the jasmine object, but does put it on the module export. Your setup would then look like this:

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

also you need to verify that xmloutput directory exist!




回答2:


To complete the answer, if the output is still not generating,

Try adding these configuration line to your protractor exports.config object :

framework: "jasmine2",
onPrepare: function() {
    var jasmineReporters = require('jasmine-reporters');
.......
}


来源:https://stackoverflow.com/questions/25228472/jasmine-reporters-is-not-generating-any-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!