jasmine-reporters is not generating any file
Asked Answered
M

2

1

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?

Modernity answered 10/8, 2014 at 12:10 Comment(7)
have you tried new jasmine.JUnitXmlReporter('reports', true, true, prePendStr); instead of the jasmineReporters ?Bigwig
yes, i get : TypeError: undefined is not a functionModernity
that is strange, because you call it a little earlier jasmine.getEnv(). When I started using this reporter for me it also did not write files and when I investigated the junitXmlReporter in mij node_modules dir I found out it did not have the parameters that I expected it to have from other peoples postings on stackoverflow. Maybe that also causes a unlogged error in your setup.Bigwig
@AndrePaap it just mean that jasmine those not contain JUnitXmlReporter for some reason, i tried to re-install it and it didn't work, i don't get an error if i use jasmineReporters but i don't see the file in the folder i tried both success and fail and there is no file generatedModernity
maybe I misunderstood. This is my setup: require('jasmine-reporters'); jasmine.getEnv().addReporter(new jasmine.JUnitXmlReporter('reports', true, true));. So I create JunitXmlReporter from the global jasmine, but with less paramaters. The jasmine-reports version I use can take the fourth paramaters.Bigwig
tried your solution and it didn't work, what version of jasmine are you using?Modernity
Let us continue this discussion in chat.Bigwig
M
7

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 [email protected]
    // 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 [email protected]
    // 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!

Modernity answered 10/8, 2014 at 13:3 Comment(2)
The newer versions of jasmine reporters no longer attaches to the Jasmine object, so you have to use the export. var jasmineReporters = require('jasmine-reporters'); ... new jasmineReporters.JUnitXmlReporter('xmloutput', true, true) ...Wingback
@Wingback you should've added that as an answer and it should've been the accepted oneMonstrosity
C
0

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');
.......
}
Chorography answered 24/6, 2015 at 12:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.