Socket
Socket
Sign inDemoInstall

protractor-jasmine2-screenshot-reporter

Package Overview
Dependencies
5
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.3 to 0.1.4

98

index.js

@@ -18,5 +18,5 @@ var fs = require('fs'),

marks = {
pending:'<span style="padding:0 1em;color:orange;">~</span>',
failed: '<span style="padding:0 1em;color:red;">&#10007;</span>',
passed: '<span style="padding:0 1em;color:green;">&#10003;</span>'
pending:'<span class="pending">~</span>',
failed: '<span class="failed">&#10007;</span>',
passed: '<span class="passed">&#10003;</span>'
};

@@ -73,2 +73,30 @@

var isSpecValid = function (spec) {
// Don't screenshot skipped specs
var isSkipped = opts.ignoreSkippedSpecs && spec.status === 'pending';
// Screenshot only for failed specs
var isIgnored = opts.captureOnlyFailedSpecs && spec.status !== 'failed';
return !isSkipped && !isIgnored;
};
var hasValidSpecs = function (suite) {
var validSuites = false;
var validSpecs = false;
if (suite._suites.length) {
validSuites = _.any(suite._suites, function(s) {
return hasValidSpecs(s);
});
}
if (suite._specs.length) {
validSpecs = _.any(suite._specs, function(s) {
return isSpecValid(s);
});
}
return validSuites || validSpecs;
};
// TODO: more options

@@ -135,10 +163,5 @@ opts = opts || {};

// Don't screenshot skipped specs
var isSkipped = opts.ignoreSkippedSpecs && spec.status === 'pending';
// Screenshot only for failed specs
var isIgnored = opts.captureOnlyFailedSpecs && spec.status !== 'failed';
if (isSkipped || isIgnored) {
_.pull(runningSuite._specs, spec);
return;
if (!isSpecValid(spec)) {
spec.isPrinted = true;
return;
}

@@ -179,16 +202,21 @@

this.jasmineDone = function() {
var htmlReport = fs.openSync(opts.dest + opts.filename, 'w');
var output = '';
var output = '<html><head><meta charset="utf-8"><style>body{font-family:Arial;}ul{list-style-position: inside;}.passed{padding: 0 1em;color:green;}.failed{padding: 0 1em;color:red;}.pending{padding: 0 1em;color:red;}</style></head><body>';
_.each(suites, function(suite) {
output += printResults(suite);
});
_.each(suites, function(suite) {
output += printResults(suite);
});
// Ideally this shouldn't happen, but some versions of jasmine will allow it
_.each(specs, function(suite) {
output += printSpec(suite);
});
// Ideally this shouldn't happen, but some versions of jasmine will allow it
_.each(specs, function(spec) {
output += printSpec(spec);
});
fs.writeSync(htmlReport, output, 0);
fs.closeSync(htmlReport);
output += '</body></html>';
fs.appendFileSync(opts.dest + opts.filename, output, {encoding: 'utf8'}, function(err){
if(err){
console.error('Error writing to file:' + opts.dest + opts.filename);
throw err;
}
});
};

@@ -198,23 +226,21 @@

var printedSpecs = [];
function printSpec(spec) {
var suiteName = spec._suite ? spec._suite.fullName : '';
if (_.contains(printedSpecs, spec.id)) {
if (spec.isPrinted) {
return '';
}
printedSpecs.push(spec.id);
return '<li>' + marks[spec.status] + '<a href="' + spec.filename + '">' + spec.fullName.replace(suiteName, '').trim() + '</a> (' + getDuration(spec) + ' s)</li>';
spec.isPrinted = true;
return '<li>' + marks[spec.status] + '<a href="' + encodeURIComponent(spec.filename) + '">' + spec.fullName.replace(suiteName, '').trim() + '</a> (' + getDuration(spec) + ' s)' + printReasonsForFailure(spec) + '</li>';
}
// TODO: proper nesting -> no need for magic
var printedSuites = [];
function printResults(suite) {
var output = '';
if (_.contains(printedSuites, suite.id)) {
if (suite.isPrinted || !hasValidSpecs(suite)) {
return '';
}
printedSuites.push(suite.id);
suite.isPrinted = true;

@@ -240,2 +266,16 @@ output += '<ul style="list-style-type:none">';

function printReasonsForFailure(spec) {
if (spec.status !== 'failed') {
return '';
}
var reasons = '<ul>';
_.each(spec.failedExpectations, function(exp) {
reasons += '<li>' + exp.message + '</li>';
});
reasons += '</ul>';
return reasons;
}
return this;

@@ -242,0 +282,0 @@ }

{
"name": "protractor-jasmine2-screenshot-reporter",
"version": "0.1.3",
"version": "0.1.4",
"description": "Use the screenshot reporter to capture screenshots after each executed Protractor test case.",

@@ -14,3 +14,2 @@ "main": "index.js",

"mkdirp": "^0.5.0",
"path": "^0.11.14",
"string.prototype.startswith": "^0.2.0"

@@ -42,4 +41,7 @@ },

"url": "http://www.asnovikov.ru/"
},
{
"name": "Sandeep Adinarayana"
}
]
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc