forked from bcole/protractor-angular-screenshot-reporter
-
Notifications
You must be signed in to change notification settings - Fork 40
Add additional reporters (JUnitXmlReporter, SpecReporter)
Ramon Klein edited this page Sep 18, 2018
·
1 revision
You can combine protractor-beautiful-reporter with other jasmine reporters.
Here see an example with two additional reporters:
const jasmineReporters= require('jasmine-reporters');
const {SpecReporter} = require('jasmine-spec-reporter');
const HtmlReporter = require('protractor-beautiful-reporter');
const path = require('path');
// ----- Config example for Jasmine 2 -----
exports.config = {
seleniumAddress: 'http://192.168.0.19:4444/wd/hub',
onPrepare: function () {
jasmine.getEnv().clearReporters();
jasmine.getEnv().addReporter(
new SpecReporter({spec: {displayStacktrace: true}})
);
jasmine.getEnv().addReporter(new jasmineReporters.JUnitXmlReporter({
savePath: 'reports-tmp',
consolidateAll: true
}));
// 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());
},
// Spec patterns are relative to the location of this config.
specs: [
'./specs/*.js'
],
// https://code.google.com/p/selenium/source/browse/javascript/webdriver/capabilities.js
capabilities: {
browserName: 'chrome',
logName: 'Chrome - English',
version: '',
platform: 'ANY',
shardTestFiles: false,
maxInstances: 2,
chromeOptions: {
args:["--window-size=1680,1000"]
}
},
// A base URL for your application under test. Calls to protractor.get()
// with relative paths will be prepended with this.
baseUrl: 'http://www.yourtest.test/',
// Set the framework
framework: 'jasmine',
jasmineNodeOpts: {
// If true, print colors to the terminal.
showColors: true,
// Default time to wait in ms before a test fails.
defaultTimeoutInterval: 10000,
}
};