Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed: OS column in report is empty #173

Merged
merged 1 commit into from
Sep 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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