protractore2e-testingjasmine2.0

Cleandestination in jasmine html reporter is not working


I am using the following code to generate HTML report for e2e testing in protractor.

jasmine.getEnv().addReporter(new HtmlReporter({
     baseDirectory: './e2e/e2e_coverage/',
     savePath: './e2e/e2e_coverage/',
     screenshotsFolder: 'images',
     takeScreenShotsOnlyForFailedSpecs: true,
     cleanDestination: true,
     fixedScreenshotName: true,
     htmlReportDir: './e2e/e2e_coverage/htmlReports/',
     jsonsSubfolder: 'jsons',
     docTitle: 'HTMLreport.html'
     }).getJasmine2Reporter());

Here, clean destination is not cleaning the previous run results. It is appending the previous run results which is generating duplicate results in HTML report.

I am using protractor-beautiful-reporter version 1.2.7.

Please let me know what I am missing.


Solution

  • Try the below in your onPrepare()

     // Add a screenshot reporter:
            jasmine.getEnv().addReporter(new HtmlReporter({
                preserveDirectory: false,
                takeScreenShotsOnlyForFailedSpecs: true,
                screenshotsSubfolder: 'images',
                jsonsSubfolder: 'jsons',
                baseDirectory: 'reports-tmp',
    
                pathBuilder: function pathBuilder(spec, descriptions, results, capabilities) {
                    // Return '<30-12-2016>/<browser>/<specname>' as path for screenshots:
                    // Example: '30-12-2016/firefox/list-should work'.
                    var currentDate = new Date(),
                        day = currentDate.getDate(),
                        month = currentDate.getMonth() + 1,
                        year = currentDate.getFullYear();
    
                    var validDescriptions = descriptions.map(function (description) {
                        return description.replace('/', '@');
                    });
    
                    return path.join(
                        day + "-" + month + "-" + year,
                        // capabilities.get('browserName'),
                        validDescriptions.join('-'));
                }
            }).getJasmine2Reporter());
    

    There is no cleanDestinationoption in protractor-beautiful-reporter version 1.2.7.

    Hope preserveDirectory: false, would help you.