Reputation: 5
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.
Upvotes: 0
Views: 798
Reputation: 1980
You can achieve this easily with below code . I tested in Version 5.4.2 of protractor with https://www.npmjs.com/package/protractor-beautiful-reporter
// protractor beautifulreporterconfig.js
//Add this import with path to exact node module to avoid the error
var HtmlReporter = require('C:/Users/sam/AppData/Roaming/npm/node_modules/protractor-beautiful-reporter');
exports.config = {
//directConnect: true,
framework: 'jasmine',
//if your spec.js only have none angular scripts
onPrepare: function () {
// browser.driver.ignoreSynchronization = true;// for non-angular set true. default value is false
//browser.waitForAngularEnabled(false); // for non-angular set false. default value is true
browser.driver.manage().window().setSize(1280, 1024);
},
capabilities: {
browserName: 'chrome',
chromeOptions: {
args: [ "--start-maximized" ]
}
},
jasmineNodeOpts: {
//Jasmine provides only one timeout option timeout in milliseconds don't add ;
defaultTimeoutInterval: 180000
},
onPrepare: function() {
// Add a screenshot reporter and store screenshots to `/Reports/screenshots`:
jasmine.getEnv().addReporter(new HtmlReporter({
baseDirectory: 'HtmlReports',
screenshotsSubfolder: 'images', //sub folder for screenshots
//Below settings are optional
//Add title for the html report (optional)
docTitle: 'my beautiful reporter',
jsonsSubfolder: 'jsons',//You can store all JSONs in subfolder by using jsonsSubfolder option:
//Exclude report for skipped test cases (optional)
excludeSkippedSpecs: false,//default is false
//Screenshots for skipped test cases (optional) Default is false.
takeScreenShotsForSkippedSpecs: false,
//Screenshots only for failed test cases (optional) default is false
takeScreenShotsOnlyForFailedSpecs: false,
//To Disable all screenshots default is false
disableScreenshots: false,
//You can gather browser logs using gatherBrowserLogs: option: default is true
gatherBrowserLogs: true ,
//You can preserve (or clear) the base directory using preserveDirectory: option:Default is true.
// it it is true , report folder get cleared before the execution
//If you want to show the total duration in the header or footer area...
preserveDirectory: false,
clientDefaults:{
showTotalDurationIn: "header",
totalDurationFormat: "hms"
}
}).getJasmine2Reporter());
},
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['src/com/sam/scriptjs/radiobutton.spec.js']
}
Upvotes: 0
Reputation: 1442
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 cleanDestination
option in protractor-beautiful-reporter version 1.2.7
.
Hope preserveDirectory: false,
would help you.
Upvotes: 1