I am afraid there is no easy answer to this question, since Protractor overwrites report files when using any custom plugins. But below two worked for me. Choose what suits you best
1) Tinker with 'index.js' Jasmine2HtmlReporter to add a file instead of PhantomJs overwrites its use
2) Create unique HTML reports by setting up the Jasmine2HTML reporter from the onPrepare () function and consolidating all reports later
SOLUTION 1: The current Jasmine2HtmlReporter code base - index.jsuses two functions - phantomWrite()and nodeWrite()for writing data. Contact here
- appendwrite() ,
github, protractor-jasmine2-html-reporter
function appendwrite(path, filename, text){
var fs = require("fs");
var nodejs_path = require("path");
require("mkdirp").sync(path); // make sure the path exists
var filepath = nodejs_path.join(path, filename);
fs.appendFileSync(filepath,text)
return;
}
self.writeFile 'node_modules/protractor-jasmine2-html-reporter/index.js',
try {
appendwrite(path, filename, text);
//phantomWrite(path, filename, text);
return;
} catch (e) { errors.push(' PhantomJs attempt: ' + e.message); }
try {
nodeWrite(path, filename, text);
return;
} catch (f) { errors.push(' NodeJS attempt: ' + f.message); }
, , - CleanUpCode
rmdir(self.savePath);
2: sessionID , OnPrepare
onPrepare: function() {
return new Promise(function (fulfill, reject) {
browser.getCapabilities().then(function (value) {
reportName = value.get('webdriver.remote.sessionid') + '_' + value.get('browserName') + '_' + Math.floor(Math.random()*1E16);
jasmine.getEnv().addReporter(
new Jasmine2HtmlReporter({
savePath: 'target/',
screenshotsFolder: 'images',
consolidate: true,
consolidateAll: true,
filePrefix: reportName + ".html"
})
);
fulfill();
})
});
},
2: , afterLaunch() webdriver
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');
},
, - ConsolidatedReport
PS: , .

protractor-jasmine2-html- , 'shardTestFiles': true conf