Protractor jasmine html reporter中的Cleandestination不工作
我正在使用以下代码为量角器中的e2e测试生成Protractor jasmine html reporter中的Cleandestination不工作,protractor,e2e-testing,jasmine2.0,Protractor,E2e Testing,Jasmine2.0,我正在使用以下代码为量角器中的e2e测试生成HTML报告 jasmine.getEnv().addReporter(new HtmlReporter({ baseDirectory: './e2e/e2e_coverage/', savePath: './e2e/e2e_coverage/', screenshotsFolder: 'images', takeScreenShotsOnlyForFailedSpecs: true, cleanDe
HTML
报告
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());
在这里,clean destination不是清除以前的运行结果。它附加上一次运行结果,该结果在HTML
报告中生成重复结果
我使用的是量角器Beauty reporter 1.2.7版
请让我知道我遗漏了什么。请在您的
onPrepare()中尝试以下内容。
//添加屏幕截图报告器:
jasmine.getEnv().addReporter(新的HtmlReporter({
保存目录:false,
对于不合格的规格,只拍摄屏幕快照:正确,
屏幕快照文件夹:“图像”,
jsons子文件夹:“jsons”,
baseDirectory:'报告tmp',
pathBuilder:函数pathBuilder(规格、说明、结果、功能){
//返回“//”作为屏幕截图的路径:
//示例:“30-12-2016/firefox/list应该可以使用”。
var currentDate=新日期(),
day=currentDate.getDate(),
月份=currentDate.getMonth()+1,
年份=当前日期。getFullYear();
var validDescriptions=descriptions.map(函数(描述){
返回说明。替换(“/”、“@”);
});
返回路径.join(
日+“-”+月+“-”+年,
//capabilities.get('browserName'),
validDescriptions.join('-');
}
}).getJasmine2Reporter());
在量角器Beauty reporter 1.2.7版
中没有cleanDestination
选项
希望
preserveDirectory:false,
会对您有所帮助。您可以使用下面的代码轻松实现这一点。我在5.4.2版量角器中使用
谢谢madhan,添加了preserveDirectory:false本身就起作用了。
// 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());
// 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']
}