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

probe.gl

Package Overview
Dependencies
Maintainers
5
Versions
91
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

probe.gl - npm Package Compare versions

Comparing version 2.2.0-beta.1 to 2.2.0-beta.2

4

CHANGELOG.md
CHANGELOG
v2.2.0-beta.2 - Jan 30, 2019
- Expose isHeadless function
- Add API to save screenshot to disk
v2.2.0-beta.1 - Jan 30, 2019

@@ -4,0 +8,0 @@ - Browser test tools

2

dist/es5/lib/utils/globals.js

@@ -50,3 +50,3 @@ "use strict";

var VERSION = typeof "2.2.0-beta.1" !== 'undefined' ? "2.2.0-beta.1" : 'untranspiled source';
var VERSION = typeof "2.2.0-beta.2" !== 'undefined' ? "2.2.0-beta.2" : 'untranspiled source';
exports.VERSION = VERSION;

@@ -53,0 +53,0 @@ var isBrowser = (0, _isBrowser.default)();

@@ -26,2 +26,4 @@ "use strict";

var _fs = _interopRequireDefault(require("fs"));
var MAX_CONSOLE_MESSAGE_LENGTH = 500;

@@ -75,2 +77,5 @@

var exposeFunctions = Object.assign({}, config.exposeFunctions, {
browserTestDriver_isHeadless: function browserTestDriver_isHeadless() {
return _this2.headless;
},
browserTestDriver_fail: function browserTestDriver_fail() {

@@ -190,2 +195,4 @@ return _this2.failures++;

value: function _captureAndDiff(opts) {
var _this3 = this;
if (!opts.goldenImage) {

@@ -209,2 +216,16 @@ return Promise.reject(new Error('Must supply golden image for image diff'));

return (0, _diffImages.default)(image, opts.goldenImage, opts);
}).then(function (result) {
if (!result.success && opts.saveOnFail) {
var filename = typeof opts.saveOnFail === 'string' ? opts.saveOnFail : '[name]-failed.png';
filename = filename.replace('[name]', opts.goldenImage.replace(/\.\w+$/, ''));
_this3._saveScreenshot(filename, result.source1);
}
return {
match: result.match,
matchPercentage: result.matchPercentage,
success: result.success,
diffImage: result.diffImage
};
}).catch(function (error) {

@@ -218,2 +239,21 @@ return {

}
}, {
key: "_saveScreenshot",
value: function _saveScreenshot(filename, data) {
var _this4 = this;
this.logger.log({
message: "Writing screenshot to ".concat(filename),
color: _color.COLOR.BRIGHT_YELLOW
})();
_fs.default.writeFile(filename, data, function (error) {
if (error) {
_this4.logger.log({
message: "Save screenshot failed: ".concat(error.message),
color: _color.COLOR.BRIGHT_RED
})();
}
});
}
}]);

@@ -220,0 +260,0 @@ return BrowserTestDriver;

@@ -25,3 +25,8 @@ "use strict";

return diffPNGs(image1, image2, options);
var result = diffPNGs(image1, image2, options);
return Object.assign(result, {
source1: source1,
source2: source2,
options: options
});
});

@@ -28,0 +33,0 @@ }

import checkIfBrowser from '../../env/is-browser';
export { self, window, global, document, process, console } from '../../env/globals';
export const VERSION = typeof "2.2.0-beta.1" !== 'undefined' ? "2.2.0-beta.1" : 'untranspiled source';
export const VERSION = typeof "2.2.0-beta.2" !== 'undefined' ? "2.2.0-beta.2" : 'untranspiled source';
export const isBrowser = checkIfBrowser();
//# sourceMappingURL=globals.js.map
import BrowserDriver from './browser-driver';
import { COLOR, addColor } from '../../lib/utils/color';
import diffImages from '../image-utils/diff-images';
import fs from 'fs';
const MAX_CONSOLE_MESSAGE_LENGTH = 500;

@@ -34,2 +35,3 @@ export default class BrowserTestDriver extends BrowserDriver {

const exposeFunctions = Object.assign({}, config.exposeFunctions, {
browserTestDriver_isHeadless: () => this.headless,
browserTestDriver_fail: () => this.failures++,

@@ -147,4 +149,18 @@ browserTestDriver_finish: message => resolve(message),

return this.page.screenshot(screenshotOptions).then(image => diffImages(image, opts.goldenImage, opts)).catch(error => {
return this.page.screenshot(screenshotOptions).then(image => diffImages(image, opts.goldenImage, opts)).then(result => {
if (!result.success && opts.saveOnFail) {
let filename = typeof opts.saveOnFail === 'string' ? opts.saveOnFail : '[name]-failed.png';
filename = filename.replace('[name]', opts.goldenImage.replace(/\.\w+$/, ''));
this._saveScreenshot(filename, result.source1);
}
return {
match: result.match,
matchPercentage: result.matchPercentage,
success: result.success,
diffImage: result.diffImage
};
}).catch(error => {
return {
success: false,

@@ -157,3 +173,18 @@ match: 0,

_saveScreenshot(filename, data) {
this.logger.log({
message: `Writing screenshot to ${filename}`,
color: COLOR.BRIGHT_YELLOW
})();
fs.writeFile(filename, data, error => {
if (error) {
this.logger.log({
message: `Save screenshot failed: ${error.message}`,
color: COLOR.BRIGHT_RED
})();
}
});
}
}
//# sourceMappingURL=browser-test-driver.js.map

@@ -5,3 +5,10 @@ import fs from 'fs';

export default function diffImages(source1, source2, options = {}) {
return Promise.all([parsePNG(source1), parsePNG(source2)]).then(([image1, image2]) => diffPNGs(image1, image2, options));
return Promise.all([parsePNG(source1), parsePNG(source2)]).then(([image1, image2]) => {
const result = diffPNGs(image1, image2, options);
return Object.assign(result, {
source1,
source2,
options
});
});
}

@@ -8,0 +15,0 @@

import checkIfBrowser from '../../env/is-browser';
export { self, window, global, document, process, console } from '../../env/globals';
export var VERSION = typeof "2.2.0-beta.1" !== 'undefined' ? "2.2.0-beta.1" : 'untranspiled source';
export var VERSION = typeof "2.2.0-beta.2" !== 'undefined' ? "2.2.0-beta.2" : 'untranspiled source';
export var isBrowser = checkIfBrowser();
//# sourceMappingURL=globals.js.map

@@ -9,2 +9,3 @@ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";

import diffImages from '../image-utils/diff-images';
import fs from 'fs';
var MAX_CONSOLE_MESSAGE_LENGTH = 500;

@@ -59,2 +60,5 @@

var exposeFunctions = Object.assign({}, config.exposeFunctions, {
browserTestDriver_isHeadless: function browserTestDriver_isHeadless() {
return _this2.headless;
},
browserTestDriver_fail: function browserTestDriver_fail() {

@@ -174,2 +178,4 @@ return _this2.failures++;

value: function _captureAndDiff(opts) {
var _this3 = this;
if (!opts.goldenImage) {

@@ -193,2 +199,16 @@ return Promise.reject(new Error('Must supply golden image for image diff'));

return diffImages(image, opts.goldenImage, opts);
}).then(function (result) {
if (!result.success && opts.saveOnFail) {
var filename = typeof opts.saveOnFail === 'string' ? opts.saveOnFail : '[name]-failed.png';
filename = filename.replace('[name]', opts.goldenImage.replace(/\.\w+$/, ''));
_this3._saveScreenshot(filename, result.source1);
}
return {
match: result.match,
matchPercentage: result.matchPercentage,
success: result.success,
diffImage: result.diffImage
};
}).catch(function (error) {

@@ -202,2 +222,20 @@ return {

}
}, {
key: "_saveScreenshot",
value: function _saveScreenshot(filename, data) {
var _this4 = this;
this.logger.log({
message: "Writing screenshot to ".concat(filename),
color: COLOR.BRIGHT_YELLOW
})();
fs.writeFile(filename, data, function (error) {
if (error) {
_this4.logger.log({
message: "Save screenshot failed: ".concat(error.message),
color: COLOR.BRIGHT_RED
})();
}
});
}
}]);

@@ -204,0 +242,0 @@

@@ -12,3 +12,8 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";

return diffPNGs(image1, image2, options);
var result = diffPNGs(image1, image2, options);
return Object.assign(result, {
source1: source1,
source2: source2,
options: options
});
});

@@ -15,0 +20,0 @@ }

@@ -5,3 +5,3 @@ {

"license": "MIT",
"version": "2.2.0-beta.1",
"version": "2.2.0-beta.2",
"keywords": [

@@ -8,0 +8,0 @@ "javascript",

@@ -24,2 +24,3 @@ // Copyright (c) 2015 - 2017 Uber Technologies, Inc.

import diffImages from '../image-utils/diff-images';
import fs from 'fs';

@@ -61,2 +62,3 @@ const MAX_CONSOLE_MESSAGE_LENGTH = 500;

const exposeFunctions = Object.assign({}, config.exposeFunctions, {
browserTestDriver_isHeadless: () => this.headless,
browserTestDriver_fail: () => this.failures++,

@@ -182,2 +184,16 @@ browserTestDriver_finish: message => resolve(message),

.then(image => diffImages(image, opts.goldenImage, opts))
.then(result => {
if (!result.success && opts.saveOnFail) {
let filename =
typeof opts.saveOnFail === 'string' ? opts.saveOnFail : '[name]-failed.png';
filename = filename.replace('[name]', opts.goldenImage.replace(/\.\w+$/, ''));
this._saveScreenshot(filename, result.source1);
}
return {
match: result.match,
matchPercentage: result.matchPercentage,
success: result.success,
diffImage: result.diffImage
};
})
.catch(error => {

@@ -187,2 +203,17 @@ return {success: false, match: 0, error: error.message};

}
_saveScreenshot(filename, data) {
this.logger.log({
message: `Writing screenshot to ${filename}`,
color: COLOR.BRIGHT_YELLOW
})();
fs.writeFile(filename, data, error => {
if (error) {
this.logger.log({
message: `Save screenshot failed: ${error.message}`,
color: COLOR.BRIGHT_RED
})();
}
});
}
}

@@ -7,5 +7,10 @@ /* global Buffer */

export default function diffImages(source1, source2, options = {}) {
return Promise.all([parsePNG(source1), parsePNG(source2)]).then(([image1, image2]) =>
diffPNGs(image1, image2, options)
);
return Promise.all([parsePNG(source1), parsePNG(source2)]).then(([image1, image2]) => {
const result = diffPNGs(image1, image2, options);
return Object.assign(result, {
source1,
source2,
options
});
});
}

@@ -12,0 +17,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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