最近我们已经将我们的 e2e 测试配置为在 Jenkins 上,很快我们意识到我们必须使用共享测试文件:真正的选项,因为完整的套件运行需要很长时间,我们每天要花 9 到 10 个小时来查看。但是当我们在 conf 文件中配置以下两个选项时。测试运行良好,但最终报告仅在保存路径中显示最后的规范运行结果。合并所有选项不提供完整报告。
请找到我们的 conf 文件详细信息。任何帮助将不胜感激。
根据 Aditya 提供的解决方案编辑 conf 文件。请帮忙
var Jasmine2HtmlReporter = require('protractor-jasmine2-html-reporter');
var log4js = require('log4js');
var params = process.argv;
var args = process.argv.slice(3);
exports.config = {
//seleniumServerJar: './node_modules/gulp-protractor/node_modules/protractor/selenium/selenium-server-standalone-2.48.2.jar',
seleniumAddress: 'http://localhost:4444/wd/hub',
allScriptsTimeout: 100000,
framework: 'jasmine2',
onPrepare: function () {
return new Promise(function(fulfill, reject) {
browser.getCapabilities().then(function(value) {
reportName = value.get(Math.random(8,2)) + '_' + value.get('browserName') + '_' + Math.floor(Math.random() * 1E16);
jasmine.getEnv().addReporter(
new Jasmine2HtmlReporter({
//cleanDestination: false,
savePath: __dirname+'/target',
//docTitle: 'Web UI Test Report',
screenshotsFolder: 'image',
//takeScreenshots: true,
takeScreenshotsOnlyOnFailures: true,
consolidate: true,
consolidateAll: true,
preserveDirectory: true,
//fixedScreenshotName: true,
filePrefix: reportName + ".html"
})
);
fulfill();
});
});
// browser.manage().timeouts().implicitlyWait(11000);
var width = 768;
var height = 1366;
browser.driver.manage().window().setSize(768, 1366);
browser.ignoreSynchronization = false;
},
afterLaunch: function afterLaunch() {
var fs = require('fs');
var output = '';
fs.readdirSync('target/').forEach(function (file) {
if (!(fs.lstatSync('target/' + file).isDirectory()))
output = output + fs.readFileSync('target/' + file);
});
fs.writeFileSync('target/ConsolidatedReport.html', output, 'utf8');
},
suites:{
example:['./test/e2e/specs/**/*Spec.js',]
},
/* capabilities: {
'browserName': 'chrome'
},*/
multiCapabilities: [
{
'browserName': 'chrome'
},
{
'browserName': 'firefox'
}
],
resultJsonOutputFile:'./results.json',
// Options to be passed to Jasmine-node.
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 100000
}
};