Skip to content

Commit

Permalink
Merge pull request #173 from Evilweed/fixplatform
Browse files Browse the repository at this point in the history
Fixed: OS column in report is empty
  • Loading branch information
miller45 authored Sep 11, 2019
2 parents d2330b7 + 7f255eb commit e131a91
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 108 deletions.
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Changelog
## Version 1.3.2
* Fixed: OS column in report is empty (with browsers other than chrome)
* Removed: Unused code for jasmine 1 (defaultMetadataBuilder)
## Version 1.3.1
* Fixed: Template files could not be loaded because of CORS violation when run from filesystem
## Version 1.3.0
Expand Down
59 changes: 4 additions & 55 deletions app/reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,65 +22,16 @@ function defaultPathBuilder(spec, descriptions, results, capabilities) {
return util.generateGuid();
}

/** Function: defaultMetaDataBuilder
* Uses passed information to generate a meta data object which can be saved
* along with a screenshot.
* You do not have to add the screenshots file path since this will be appended
* automatically.
*
* Parameters:
* (Object) spec - The spec currently reported
* (Array) descriptions - The specs and their parent suites descriptions
* (Object) result - The result object of the current test spec.
* (Object) capabilities - WebDrivers capabilities object containing
* in-depth information about the Selenium node
* which executed the test case.
*
* Returns:
* (Object) containing meta data to store along with a screenshot
*/
function defaultMetaDataBuilder(spec, descriptions, results, capabilities) {
var metaData = {
description: descriptions.join(' '),
passed: results.passed(),
os: capabilities.caps_.platform,
sessionId: capabilities.caps_['webdriver.remote.sessionid'],
instanceId: process.pid,
browser: {
name: capabilities.caps_.browserName,
version: capabilities.caps_.version
}
};

if (results.items_.length > 0) {
var result = results.items_[0];
if (!results.passed()) {
var failedItem = _.where(results.items_, {passed_: false})[0];
if (failedItem) {
metaData.message = failedItem.message || 'Failed';
metaData.trace = failedItem.trace ? (failedItem.trace.stack || 'No Stack trace information') : 'No Stack trace information';
}

} else {
metaData.message = result.message || 'Passed';
metaData.trace = result.trace.stack;
}

}

return metaData;
}

function jasmine2MetaDataBuilder(spec, descriptions, results, capabilities) {

let isPassed = results.status === 'passed';
let isPending = ['pending', 'disabled', 'excluded'].includes(results.status);

let osInfo= capabilities.get("platform") || capabilities.get("platformName");
let metaData = {
description: descriptions.join(' '),
passed: isPassed,
pending: isPending,
os: capabilities.get('platform'),
os: osInfo,
sessionId: capabilities.get('webdriver.remote.sessionid'),
instanceId: process.pid,
browser: {
Expand Down Expand Up @@ -138,7 +89,7 @@ function sortFunction(a, b) {
* Mandatory.
* (Function) pathBuilder - A function which returns a path for a screenshot
* to be stored. Optional.
* (Function) metaDataBuilder - Function which returns an object literal
* (Function) jasmine2MetaDataBuilder - Function which returns an object literal
* containing meta data to store along with
* the screenshot. Optional.
* (Boolean) takeScreenShotsForSkippedSpecs - Do you want to capture a
Expand Down Expand Up @@ -175,7 +126,6 @@ function ScreenshotReporter(options) {
this.pathBuilder = options.pathBuilder || defaultPathBuilder;
this.docTitle = options.docTitle || 'Test Results';
this.docName = options.docName || 'report.html';
this.metaDataBuilder = options.metaDataBuilder || defaultMetaDataBuilder;
this.jasmine2MetaDataBuilder = options.jasmine2MetaDataBuilder || jasmine2MetaDataBuilder;
this.sortFunction = options.sortFunction || sortFunction;
this.preserveDirectory = typeof options.preserveDirectory !== 'undefined' ? options.preserveDirectory : true;
Expand All @@ -201,7 +151,6 @@ function ScreenshotReporter(options) {
takeScreenShotsOnlyForFailedSpecs: this.takeScreenShotsOnlyForFailedSpecs,
takeScreenShotsForSkippedSpecs: this.takeScreenShotsForSkippedSpecs,
disableScreenshots: this.disableScreenshots,
metaDataBuilder: this.metaDataBuilder,
pathBuilder: this.pathBuilder,
sortFunction: this.sortFunction,
baseDirectory: this.baseDirectory,
Expand Down Expand Up @@ -420,4 +369,4 @@ function nowString() {
return (new Date()).toISOString();
}

module.exports = ScreenshotReporter;
module.exports = ScreenshotReporter;
55 changes: 3 additions & 52 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4705,63 +4705,16 @@ function defaultPathBuilder(spec, descriptions, results, capabilities) {
return util.generateGuid();
}

/** Function: defaultMetaDataBuilder
* Uses passed information to generate a meta data object which can be saved
* along with a screenshot.
* You do not have to add the screenshots file path since this will be appended
* automatically.
*
* Parameters:
* (Object) spec - The spec currently reported
* (Array) descriptions - The specs and their parent suites descriptions
* (Object) result - The result object of the current test spec.
* (Object) capabilities - WebDrivers capabilities object containing
* in-depth information about the Selenium node
* which executed the test case.
*
* Returns:
* (Object) containing meta data to store along with a screenshot
*/
function defaultMetaDataBuilder(spec, descriptions, results, capabilities) {
var metaData = {
description: descriptions.join(' '),
passed: results.passed(),
os: capabilities.caps_.platform,
sessionId: capabilities.caps_['webdriver.remote.sessionid'],
instanceId: process.pid,
browser: {
name: capabilities.caps_.browserName,
version: capabilities.caps_.version
}
};

if (results.items_.length > 0) {
var result = results.items_[0];
if (!results.passed()) {
var failedItem = _.where(results.items_, { passed_: false })[0];
if (failedItem) {
metaData.message = failedItem.message || 'Failed';
metaData.trace = failedItem.trace ? failedItem.trace.stack || 'No Stack trace information' : 'No Stack trace information';
}
} else {
metaData.message = result.message || 'Passed';
metaData.trace = result.trace.stack;
}
}

return metaData;
}

function jasmine2MetaDataBuilder(spec, descriptions, results, capabilities) {

var isPassed = results.status === 'passed';
var isPending = ['pending', 'disabled', 'excluded'].includes(results.status);

var osInfo = capabilities.get("platform") || capabilities.get("platformName");
var metaData = {
description: descriptions.join(' '),
passed: isPassed,
pending: isPending,
os: capabilities.get('platform'),
os: osInfo,
sessionId: capabilities.get('webdriver.remote.sessionid'),
instanceId: process.pid,
browser: {
Expand Down Expand Up @@ -4819,7 +4772,7 @@ function sortFunction(a, b) {
* Mandatory.
* (Function) pathBuilder - A function which returns a path for a screenshot
* to be stored. Optional.
* (Function) metaDataBuilder - Function which returns an object literal
* (Function) jasmine2MetaDataBuilder - Function which returns an object literal
* containing meta data to store along with
* the screenshot. Optional.
* (Boolean) takeScreenShotsForSkippedSpecs - Do you want to capture a
Expand Down Expand Up @@ -4855,7 +4808,6 @@ function ScreenshotReporter(options) {
this.pathBuilder = options.pathBuilder || defaultPathBuilder;
this.docTitle = options.docTitle || 'Test Results';
this.docName = options.docName || 'report.html';
this.metaDataBuilder = options.metaDataBuilder || defaultMetaDataBuilder;
this.jasmine2MetaDataBuilder = options.jasmine2MetaDataBuilder || jasmine2MetaDataBuilder;
this.sortFunction = options.sortFunction || sortFunction;
this.preserveDirectory = typeof options.preserveDirectory !== 'undefined' ? options.preserveDirectory : true;
Expand All @@ -4879,7 +4831,6 @@ function ScreenshotReporter(options) {
takeScreenShotsOnlyForFailedSpecs: this.takeScreenShotsOnlyForFailedSpecs,
takeScreenShotsForSkippedSpecs: this.takeScreenShotsForSkippedSpecs,
disableScreenshots: this.disableScreenshots,
metaDataBuilder: this.metaDataBuilder,
pathBuilder: this.pathBuilder,
sortFunction: this.sortFunction,
baseDirectory: this.baseDirectory,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "protractor-beautiful-reporter",
"version": "1.3.1",
"version": "1.3.2",
"description": "An npm module and which generates your Protractor test reports in HTML (angular) with screenshots",
"main": "index.js",
"repository": {
Expand Down

0 comments on commit e131a91

Please sign in to comment.