Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

protractor-jasmine2-screenshot-reporter

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

protractor-jasmine2-screenshot-reporter - npm Package Compare versions

Comparing version 0.0.5 to 0.1.0

43

index.js

@@ -28,2 +28,15 @@ var fs = require('fs'),

var writeMetadata = function(data, filename) {
var stream;
try {
stream = fs.createWriteStream(filename);
stream.write(JSON.stringify(data, null, '\t'));
stream.end();
} catch(e) {
console.error('Couldn\'t save metadata: ' + filename);
}
};
// returns suite clone or creates one

@@ -54,2 +67,6 @@ var getSuiteClone = function(suite) {

var metadataBuilder = function(spec, suites, capabilities) {
return false;
};
// TODO: more options

@@ -62,2 +79,3 @@ opts = opts || {};

opts.pathBuilder = opts.pathBuilder || pathBuilder;
opts.metadataBuilder = opts.metadataBuilder || metadataBuilder;

@@ -127,8 +145,25 @@

browser.getCapabilities().then(function (capabilities) {
spec.filename = opts.pathBuilder(spec, suites, capabilities) + '.png';
var fullpath = path.join(opts.dest, spec.filename);
var screenshotPath,
metadataPath,
metadata,
file;
mkdirp(path.dirname(fullpath), function(err) {
file = opts.pathBuilder(spec, suites, capabilities);
spec.filename = file + '.png';
screenshotPath = path.join(opts.dest, spec.filename);
metadata = opts.metadataBuilder(spec, suites, capabilities);
if (metadata) {
metadataPath = path.join(opts.dest, file + '.json');
mkdirp(path.dirname(metadataPath), function(err) {
if(err) {
throw new Error('Could not create directory for ' + metadataPath);
}
writeMetadata(metadata, metadataPath);
});
}
mkdirp(path.dirname(screenshotPath), function(err) {
if(err) {
throw new Error('Could not create directory for ' + fullpath);
throw new Error('Could not create directory for ' + screenshotPath);
}

@@ -135,0 +170,0 @@ writeScreenshot(png, spec.filename);

2

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

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -82,1 +82,14 @@ ## Protractor screenshot reporter for Jasmine2

By default, the path builder will generate a random ID for each spec.
### Metadata Builder (optional)
Function used to build custom metadata objects for each spec. Files (json) will use the same filename and path as created by Path Builder.
For example:
<pre><code>jasmine.getEnv().addReporter(new ScreenShotReporter({
metadataBuilder: function(currentSpec, suites, browserCapabilities) {
return { id: spec.id, os: browserCapabilities.browserName };
}
}));</code></pre>
By default, the runner builder will not save any metadata except the actual html report.
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc