Comparing version 1.0.1 to 1.0.2
Changelog | ||
========= | ||
v1.0.2 - Added image save methods (17/12/2014) | ||
v1.0.1 - Add missing percentage sign and documentation (12/12/2014) | ||
v1.0.0 - Initial release (11/12/14) | ||
v1.0.0 - Initial release (11/12/2014) |
64
index.js
var BlinkDiff = require('blink-diff'), | ||
PNGImage = require('png-image'), | ||
assert = require('assert'), | ||
@@ -68,2 +69,61 @@ path = require('path'), | ||
/** | ||
* Saves an image of the screen | ||
* | ||
* @method saveScreen | ||
* @example | ||
* browser.pixdiff.saveScreen('imageA'); | ||
* | ||
* @param {string} tag | ||
* @public | ||
*/ | ||
saveScreen: function (tag) { | ||
return this._flow.execute(function () { | ||
return browser.takeScreenshot() | ||
.then(function (image) { | ||
tag = util.format('%s-%s-%sx%s.png', tag, this._capabilities.browserName, this._width, this._height); | ||
return new PNGImage({ | ||
imagePath: new Buffer(image, 'base64'), | ||
imageOutputPath: path.join(this._basePath, tag) | ||
}).runWithPromise(); | ||
}.bind(this)); | ||
}.bind(this)); | ||
}, | ||
/** | ||
* Saves an image of the screen region | ||
* | ||
* @method saveRegion | ||
* @example | ||
* browser.pixdiff.saveRegion(element(By.id('elementId')), 'imageA'); | ||
* | ||
* @param {promise} element | ||
* @param {string} tag | ||
* @public | ||
*/ | ||
saveRegion: function (element, tag) { | ||
var size, | ||
rect; | ||
return this._flow.execute(function () { | ||
return element.getSize() | ||
.then(function (elementSize) { | ||
size = elementSize; | ||
return element.getLocation(); | ||
}) | ||
.then(function (point) { | ||
rect = {height: size.height, width: size.width, x: point.x, y: point.y}; | ||
return browser.takeScreenshot(); | ||
}) | ||
.then(function (image) { | ||
tag = util.format('%s-%s-%sx%s.png', tag, this._capabilities.browserName, this._width, this._height); | ||
return new PNGImage({ | ||
imagePath: new Buffer(image, 'base64'), | ||
imageOutputPath: path.join(this._basePath, tag), | ||
cropImage: rect | ||
}).runWithPromise(); | ||
}.bind(this)); | ||
}.bind(this)); | ||
}, | ||
/** | ||
* Runs the comparison against the screen | ||
@@ -73,3 +133,3 @@ * | ||
* @example | ||
* browser.pixImage.checkScreen('imageA', {debug: true}); | ||
* browser.pixdiff.checkScreen('imageA', {debug: true}); | ||
* | ||
@@ -107,3 +167,3 @@ * @param {string} tag | ||
* @example | ||
* browser.pixImage.checkScreen(element(By.id('elementId')), 'imageA', {debug: true}); | ||
* browser.pixdiff.checkRegion(element(By.id('elementId')), 'imageA', {debug: true}); | ||
* | ||
@@ -110,0 +170,0 @@ * @param {promise} element |
{ | ||
"name": "pix-diff", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Protractor plugin for image comparison", | ||
"main": "index.js", | ||
"dependencies": { | ||
"blink-diff": "^1.0.7", | ||
"png-image": "^1.0.0" | ||
}, | ||
"devDependencies": {}, | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/koola/pix-diff.git" | ||
}, | ||
"keywords": [ | ||
"image-diff", | ||
"pix", | ||
"blink", | ||
"image", | ||
"diff", | ||
"difference", | ||
"compare" | ||
], | ||
"author": "Koola", | ||
"license": "MIT", | ||
"main": "index.js", | ||
"bugs": { | ||
"url": "https://github.com/yahoo/blink-diff/issues" | ||
}, | ||
"homepage": "https://github.com/yahoo/blink-diff", | ||
"author": { | ||
"name": "koola", | ||
"email": "koola.uk@gmail.com" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/koola/pix-diff.git" | ||
}, | ||
"keywords": [ | ||
"image-diff", | ||
"pix", | ||
"blink", | ||
"image", | ||
"diff", | ||
"difference", | ||
"compare" | ||
], | ||
"dependencies": { | ||
"blink-diff": ">=1.0.7" | ||
}, | ||
"devDependencies": { | ||
"protractor": "^1.4.0" | ||
}, | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"maintainers": [ | ||
{ | ||
"name": "koola", | ||
"email": "koola.uk@gmail.com" | ||
} | ||
] | ||
"bugs": { | ||
"url": "https://github.com/koola/pix-diff/issues" | ||
}, | ||
"homepage": "https://github.com/koola/pix-diff" | ||
} |
@@ -43,3 +43,3 @@ Pix-Diff | ||
PixDiff provides two comparison methods ```checkScreen``` and ```checkRegion``` along with two jasmine matchers ```toMatch``` and ```toNotMatch```. | ||
PixDiff provides two comparison methods ```checkScreen``` and ```checkRegion``` along with two jasmine matchers ```toMatch``` and ```toNotMatch```. Two helper methods ```saveScreen``` and ```saveRegion``` are provided for saving images. | ||
@@ -127,2 +127,3 @@ **Example:** | ||
* [blink-diff](https://github.com/yahoo/blink-diff) | ||
* [png-image](https://github.com/koola/png-image) | ||
@@ -129,0 +130,0 @@ ###Dev-Dependencies |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13898
0
213
135
2
2
2
+ Addedpng-image@^1.0.0
+ Addedpng-image@1.2.0(transitive)
+ Addedpngjs@3.4.0(transitive)
+ Addedpromise@6.1.0(transitive)
Updatedblink-diff@^1.0.7