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

pix-diff

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pix-diff - npm Package Compare versions

Comparing version 1.0.8 to 1.0.9

framework/jasmine.js

2

CHANGELOG.md
Changelog
=========
v1.0.9 - Add Mocha chai matcher (22/04/2016)
v1.0.8 - Fixed protractors capabilities issues (credit to msviha)

@@ -4,0 +6,0 @@ - Added formatImageName option for custom image naming

15

Gruntfile.js

@@ -20,7 +20,13 @@ 'use strict';

run: {
protractor: {
jasmine: {
cmd: 'node_modules/.bin/protractor',
args: [
'test/protractor.conf.js'
'test/protractorJasmine.conf.js'
]
},
mocha: {
cmd: 'node_modules/.bin/protractor',
args: [
'test/protractorMocha.conf.js'
]
}

@@ -32,4 +38,5 @@ }

//tasks
grunt.registerTask('test', 'Run integration tests', ['clean:screens', 'run:protractor']);
grunt.registerTask('default', ['test']);
grunt.registerTask('jasmine', 'Run Jasmine integration tests', ['clean:screens', 'run:jasmine']);
grunt.registerTask('mocha', 'Run Mocha integration tests', ['clean:screens', 'run:mocha']);
grunt.registerTask('default', ['jasmine', 'mocha']);
};

@@ -1,3 +0,3 @@

var BlinkDiff = require('blink-diff'),
PNGImage = require('png-image'),
var blinkDiff = require('blink-diff'),
pngImage = require('png-image'),
assert = require('assert'),

@@ -49,2 +49,4 @@ path = require('path'),

assert.ok(this._capabilities.browserName, "Browser name is undefined.");
// Require PixDiff matchers
require(path.resolve('framework', data.framework));
}.bind(this));

@@ -112,3 +114,3 @@ }

.then(function(image) {
return new PNGImage({
return new pngImage({
imagePath: new Buffer(image, 'base64'),

@@ -147,3 +149,3 @@ imageOutputPath: path.join(this._basePath, this._format(this._formatString, tag))

.then(function(image) {
return new PNGImage({
return new pngImage({
imagePath: new Buffer(image, 'base64'),

@@ -180,5 +182,5 @@ imageOutputPath: path.join(this._basePath, this._format(this._formatString, tag)),

imageOutputPath: path.join(this._basePath, 'diff', path.basename(tag)),
imageOutputLimit: BlinkDiff.OUTPUT_DIFFERENT
imageOutputLimit: blinkDiff.OUTPUT_DIFFERENT
};
return new BlinkDiff(this._mergeDefaultOptions(defaults, options)).runWithPromise();
return new blinkDiff(this._mergeDefaultOptions(defaults, options)).runWithPromise();
}.bind(this))

@@ -225,6 +227,6 @@ .then(function(result) {

imageOutputPath: path.join(this._basePath, 'diff', path.basename(tag)),
imageOutputLimit: BlinkDiff.OUTPUT_DIFFERENT,
imageOutputLimit: blinkDiff.OUTPUT_DIFFERENT,
cropImageB: rect
};
return new BlinkDiff(this._mergeDefaultOptions(defaults, options)).runWithPromise();
return new blinkDiff(this._mergeDefaultOptions(defaults, options)).runWithPromise();
}.bind(this))

@@ -238,54 +240,2 @@ .then(function(result) {

/**
* Jasmine PixDiff matchers
*/
(function() {
var v1 = {
toMatchScreen: function() {
var result = this.actual,
percent = +((result.differences / result.dimension) * 100).toFixed(2);
this.message = function() {
return util.format("Image is visibly different by %s pixels, %s %", result.differences, percent);
};
return ((result.code === BlinkDiff.RESULT_IDENTICAL) || (result.code === BlinkDiff.RESULT_SIMILAR));
},
toNotMatchScreen: function() {
var result = this.actual;
this.message = function() {
return "Image is identical or near identical";
};
return ((result.code === BlinkDiff.RESULT_DIFFERENT) && (result.code !== BlinkDiff.RESULT_UNKNOWN));
}
},
v2 = {
toMatchScreen: function() {
return {
compare: function(actual, expected) {
var percent = +((actual.differences / actual.dimension) * 100).toFixed(2);
return {
pass: ((actual.code === BlinkDiff.RESULT_IDENTICAL) || (actual.code === BlinkDiff.RESULT_SIMILAR)),
message: util.format("Image is visibly different by %s pixels, %s %", actual.differences, percent)
};
}
}
},
toNotMatchScreen: function() {
return {
compare: function(actual, expected) {
return {
pass: ((actual.code === BlinkDiff.RESULT_DIFFERENT) && (actual.code !== BlinkDiff.RESULT_UNKNOWN)),
message: "Image is identical or near identical"
};
}
}
}
};
beforeEach(function() {
(/^2/.test(jasmine.version)) ? jasmine.addMatchers(v2) : this.addMatchers(v1);
});
})();
module.exports = PixDiff;
{
"name": "pix-diff",
"version": "1.0.8",
"version": "1.0.9",
"description": "Protractor plugin for image comparison",

@@ -8,6 +8,8 @@ "main": "index.js",

"blink-diff": "1.0.7",
"png-image": "1.0.0"
"png-image": "1.0.0",
"camel-case": "1.2.2"
},
"devDependencies": {
"camel-case": "^1.2.2",
"chai": "^3.5.0",
"chai-as-promised": "^5.3.0",
"grunt": "^0.4.2",

@@ -18,2 +20,3 @@ "grunt-cli": "^0.1.13",

"load-grunt-tasks": "^0.6.0",
"mocha": "^2.4.5",
"protractor": "3.2.2"

@@ -20,0 +23,0 @@ },

@@ -46,5 +46,5 @@ Pix-Diff

PixDiff provides two comparison methods ```checkScreen``` and ```checkRegion``` along with two jasmine matchers ```toMatchScreen``` and ```toNotMatchScreen```. Two helper methods ```saveScreen``` and ```saveRegion``` are provided for saving images.
PixDiff provides two comparison methods ```checkScreen``` and ```checkRegion``` along with Jasmine ```toMatchScreen``` and Mocha ```matchScreen``` matchers. Two helper methods ```saveScreen``` and ```saveRegion``` are provided for saving images.
**Example:**
**Jasmine Example:**
```javascript

@@ -58,3 +58,3 @@ describe("Example page", function() {

it("should match the page", function () {
expect(browser.pixdiff.checkScreen('example-page')).toMatchScreen();
expect(browser.pixdiff.checkScreen('examplePage')).toMatchScreen();
});

@@ -64,11 +64,11 @@

element(By.buttonText('yes')).click();
expect(browser.pixdiff.checkScreen('example-page')).toNotMatchScreen();
expect(browser.pixdiff.checkScreen('examplePage')).not.toMatchScreen();
});
it("should match the title", function () {
expect(browser.pixdiff.checkRegion(element(By.id('title')), 'example-page-title')).toMatchScreen();
expect(browser.pixdiff.checkRegion(element(By.id('title')), 'example page title')).toMatchScreen();
});
it("should match the title", function () {
expect(browser.pixdiff.checkRegion(element(By.id('title')), 'example-page-title', {
expect(browser.pixdiff.checkRegion(element(By.id('title')), 'example page title', {
blockOut: [{x: 10, y: 132, width: 100, height: 50}]})).toMatchScreen();

@@ -109,4 +109,4 @@ });

   ├── examplePage-chrome-1280x1024.png
   ├── examplePage-title-chrome-800x600.png
   └── examplePage-title-chrome-1280x1024.png
   ├── examplePageTitle-chrome-800x600.png
   └── examplePageTitle-chrome-1280x1024.png
```

@@ -154,2 +154,5 @@ The ```basePath``` directory must contain all the *approved* images. You may create subdirectories for better organisation, but the relative path should then be given in the test spec method. Failed comparisons generate a diff image under the **diff** folder.

* [protractor](https://github.com/angular/protractor)
* [mocha](https://github.com/mochajs/mocha)
* [chai](https://github.com/chaijs/chai)
* [chai-as-promised](https://github.com/domenic/chai-as-promised)

@@ -156,0 +159,0 @@ ##License

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