jasmineautomated-testsprotractorjasmine-reporters

Why does my protractor test have "no specs found" when I include jasmine-reporters in my config file?


When I comment this part out of my exports in my *.conf file, the tests run fine. When I comment it back in, the tests pass, but are blank, and the console logs "no specs found".

I've tried a variety of semicolon and curly brackets changes and it's not working. I think I had it working for awhile last night. I don't know what changed. Help please?

onPrepare: function(){

    var jasmineReporters = require('jasmine-reporters');
    var capsPromise = browser.getCapabilities();
    capsPromise.then(function(caps){
        var browserName = caps.caps_.browserName;
        var d = new Date();
        var curr_year = d.getFullYear();
        var curr_month = d.getMonth() + 1; //Months are zero based
        var curr_date = d.getDate();
        var testDate = curr_year + '-' + curr_month + '-' + curr_date;
        var testTime = d.getHours() + "-" + d.getMinutes() + "-" + d.getSeconds();
        jasmine.getEnv().addReporter(new jasmineReporters.JUnitXmlReporter({
            consolidateAll: false,
            savePath: '../testresults',
            filePrefix: browserName + '__' + testDate + '__' + testTime + '__'
        }));
    });

 }

Solution

  • Have you tried to return the capsPromise in your onPrepare function ? So your tests will wait for the getCapabilities() promise before running.

    onPrepare: function(){
        var jasmineReporters = require('jasmine-reporters');
        var capsPromise = browser.getCapabilities();
    
        return capsPromise.then(function(caps){
            var browserName = caps.caps_.browserName;
            // [..]
        });
    }