我正在使用以下代码来生成HTML
报告,以便在量角器中进行e2e测试。
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());
此处,清理目标位置不是在清理先前的运行结果。它会附加先前的运行结果,从而在HTML
报告中生成重复的结果。
我正在使用protractor-beautiful-reporter version 1.2.7
。
请让我知道我在想什么。
答案 0 :(得分:0)
在您的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());
cleanDestination
中没有protractor-beautiful-reporter version 1.2.7
选项。
希望preserveDirectory: false,
会为您提供帮助。
答案 1 :(得分:0)
您可以使用以下代码轻松实现此目的。我在5.4.2版的量角器中进行了测试 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']
}