New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.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

to
2.0.1

test/desktop.spec.js

13

CHANGELOG.md

@@ -1,11 +0,16 @@

<a name="2.0.0"></a>
# [2.0.0](https://github.com/koola/pix-diff/compare/v1.2.2...v2.0.0) (2017-01-13)
<a name="2.0.1"></a>
## [2.0.1](https://github.com/koola/pix-diff/compare/v2.0.0...v2.0.1) (2017-06-18)
### Bug Fixes
<a name="1.2.2"></a>
## [1.2.2](https://github.com/koola/pix-diff/compare/v1.2.1...v1.2.2) (2017-01-12)
* **code:** [#54](https://github.com/koola/pix-diff/issues/54) merge non-default options ([afaa786](https://github.com/koola/pix-diff/commit/afaa786))
<a name="2.0.0"></a>
# [2.0.0](https://github.com/koola/pix-diff/compare/v1.2.1...v2.0.0) (2017-01-13)
<a name="1.2.1"></a>

@@ -12,0 +17,0 @@ ## [1.2.1](https://github.com/koola/pix-diff/compare/v1.2.0...v1.2.1) (2017-01-11)

@@ -18,2 +18,17 @@ # Conventions

## Baselines
Passing the boolean parameter `baseline: true` will automatically generate images under the `basePath` directory and fail the spec when a baseline image is not found as below:
```text
`Image not found, saving current image as new baseline.`
```
Alternatively you can use helper methods `saveImage` and `saveRegion` to manually capture baseline images.
```javascript
pixDiff.saveImage('homepage');
pixDiff.saveRegion(element(By.id('elementId')), 'login');
```
## Image naming

@@ -45,3 +60,3 @@

```
```javascript
browser.pixDiff = new PixDiff(

@@ -56,1 +71,27 @@ {

```
## Test Framework matchers
Jasmine(2) and Mocha matchers are provided for convenience. Use the static `loadMatchers()` method outside of `describe` block to initiate the loading:
```javascript
const PixDiff = require('pix-diff');
PixDiff.loadMatchers();
```
The Matcher is automatically selected according to the framework specified in the protractor configuration file. If not specified, `jasmine2` is default.
```javascript
expect(pixDiff.checkScreen('homepage')).toPass();
// OR
expect(pixDiff.checkScreen('homepage')).not.toPass();
```
The `toPass` method evaluates the result object as an boolean value. Alternatively written without using matchers:
```javascript
pixDiff.checkScreen('homepage').then(result => {
expect(result.code).toEqual(PixDiff.RESULT_IDENTICAL);
});
```

@@ -70,2 +70,5 @@ ## Classes

* [.THRESHOLD_PERCENT](#PixDiff.THRESHOLD_PERCENT) : <code>string</code>
* [.OUTPUT_DIFFERENT](#PixDiff.OUTPUT_DIFFERENT) : <code>int</code>
* [.OUTPUT_SIMILAR](#PixDiff.OUTPUT_SIMILAR) : <code>int</code>
* [.OUTPUT_ALL](#PixDiff.OUTPUT_ALL) : <code>int</code>

@@ -166,2 +169,41 @@ <a name="new_PixDiff_new"></a>

<a name="PixDiff.OUTPUT_DIFFERENT"></a>
### PixDiff.OUTPUT_DIFFERENT : <code>int</code>
Create output when images are different
**Kind**: static property of <code>[PixDiff](#PixDiff)</code>
**Access:** public
**Properties**
| Name |
| --- |
| OUTPUT_DIFFERENT |
<a name="PixDiff.OUTPUT_SIMILAR"></a>
### PixDiff.OUTPUT_SIMILAR : <code>int</code>
Create output when images are similar or different
**Kind**: static property of <code>[PixDiff](#PixDiff)</code>
**Access:** public
**Properties**
| Name |
| --- |
| OUTPUT_SIMILAR |
<a name="PixDiff.OUTPUT_ALL"></a>
### PixDiff.OUTPUT_ALL : <code>int</code>
Force output of all comparisons
**Kind**: static property of <code>[PixDiff](#PixDiff)</code>
**Access:** public
**Properties**
| Name |
| --- |
| OUTPUT_ALL |
<a name="savePage"></a>

@@ -242,3 +284,3 @@

| tag | <code>string</code> | Baseline image name |
| options | <code>object</code> | Non-default Blink-Diff options |
| options | <code>object</code> | Non-default Pixel-Diff options |

@@ -269,3 +311,3 @@ **Example**

| tag | <code>string</code> | Baseline image name |
| options | <code>object</code> | Non-default Blink-Diff options |
| options | <code>object</code> | Non-default Pixel-Diff options |

@@ -297,3 +339,3 @@ **Example**

| tag | <code>string</code> | Baseline image name |
| options | <code>object</code> | Non-default Blink-Diff options |
| options | <code>object</code> | Non-default Pixel-Diff options |

@@ -300,0 +342,0 @@ **Example**

@@ -170,2 +170,38 @@ 'use strict';

/**
* Create output when images are different
*
* @static
* @property OUTPUT_DIFFERENT
* @type {int}
* @public
*/
static get OUTPUT_DIFFERENT() {
return PixelDiff.OUTPUT_DIFFERENT;
}
/**
* Create output when images are similar or different
*
* @static
* @property OUTPUT_SIMILAR
* @type {int}
* @public
*/
static get OUTPUT_SIMILAR() {
return PixelDiff.OUTPUT_SIMILAR;
}
/**
* Force output of all comparisons
*
* @static
* @property OUTPUT_ALL
* @type {int}
* @public
*/
static get OUTPUT_ALL() {
return PixelDiff.OUTPUT_ALL;
}
/**
* Merges non-default options from optionsB into optionsA

@@ -539,5 +575,7 @@ *

imageB: new Buffer(image, 'base64'),
imageOutputPath: path.join(this.diffPath, path.basename(tag)),
imageOutputPath: path.join(this.diffPath, path.basename(tag))
}, defaults);
options = Object.assign({
imageOutputLimit: PixelDiff.OUTPUT_DIFFERENT
}, defaults);
}, options);

@@ -644,3 +682,3 @@ return new PixelDiff(this._mergeDefaultOptions(defaults, options)).runWithPromise();

* @param {string} tag Baseline image name
* @param {object} options Non-default Blink-Diff options
* @param {object} options Non-default Pixel-Diff options
* @returns {object} result

@@ -682,3 +720,3 @@ * @reject {Error} - Baseline image not found

* @param {string} tag Baseline image name
* @param {object} options Non-default Blink-Diff options
* @param {object} options Non-default Pixel-Diff options
* @returns {object} result

@@ -716,3 +754,3 @@ * @reject {Error} - Baseline image not found

* @param {string} tag Baseline image name
* @param {object} options Non-default Blink-Diff options
* @param {object} options Non-default Pixel-Diff options
* @returns {object} result

@@ -747,2 +785,2 @@ * @reject {Error} - Baseline image not found

module.exports = PixDiff;
module.exports = PixDiff;
{
"name": "pix-diff",
"version": "2.0.0",
"version": "2.0.1",
"description": "Protractor plugin for image comparison",

@@ -61,4 +61,5 @@ "main": "index.js",

"promise": "7.1.1",
"protractor": "4.0.10"
"protractor": "5.1.1",
"saucelabs": "1.4.0"
}
}

@@ -70,3 +70,3 @@ Pix-Diff

- [x] Update Jasmine/Mocha matchers
- [ ] Enable FF after [#4253](https://github.com/angular/protractor/issues/4253) is fixed

@@ -73,0 +73,0 @@ ## License

@@ -7,3 +7,3 @@ 'use strict';

config.specs = ['../jasmine.spec.js'];
config.specs = ['../desktop.spec.js'];

@@ -16,19 +16,5 @@ config.devicePixelRatio = { 'chrome': 2, 'firefox': 1 };

logName: 'Chrome',
maxInstances: 2,
shardTestFiles: true,
chromeOptions: {
args: [
'--disable-cache',
'--disable-application-cache',
'--disable-offline-load-stale-cache',
'--disk-cache-size=0',
'--v8-cache-options=off'
]
args: ['disable-infobars']
}
},
{
browserName: 'firefox',
logName: 'Firefox',
maxInstances: 2,
shardTestFiles: true
}

@@ -35,0 +21,0 @@ ];

'use strict';
let config = require('./protractor.shared.conf.js').config;
let SauceLabs = require('saucelabs');
const sauceUsername = process.env.SAUCE_USERNAME,
sauceAccessKey = process.env.SAUCE_ACCESS_KEY,
travisBuild = process.env.TRAVIS_JOB_NUMBER,
desktopSpecs = ['../jasmine.spec.js'],
mobileSpecs = ['../mobile.spec.js'];
const SAUCE_USERNAME = process.env.SAUCE_USERNAME;
const SAUCE_ACCESS_KEY = process.env.SAUCE_ACCESS_KEY;
const TRAVIS_JOB_ID = process.env.TRAVIS_JOB_NUMBER;
const desktopSpecs = ['../desktop.spec.js'];
const mobileSpecs = ['../mobile.spec.js'];
config.seleniumAddress = travisBuild ? 'http://localhost:4445/wd/hub' : 'http://ondemand.saucelabs.com:80/wd/hub';
let JOB_ID;
config.seleniumAddress = 'http://ondemand.saucelabs.com:80/wd/hub';
config.devicePixelRatio = {

@@ -24,13 +27,14 @@ 'chrome': 1,

name: 'iPhone',
appiumVersion: '1.6.3',
browserName: 'Safari',
deviceName: 'iPhone Simulator',
deviceName: 'iPhone 6 Simulator',
deviceOrientation: 'portrait',
platformName: 'iOS',
platformVersion: '10.0',
logName: 'iPhone 6 Simulator Safari',
username: sauceUsername,
accessKey: sauceAccessKey,
build: travisBuild,
'tunnel-identifier': travisBuild,
username: SAUCE_USERNAME,
accessKey: SAUCE_ACCESS_KEY,
build: TRAVIS_JOB_ID,
'tunnel-identifier': TRAVIS_JOB_ID,
shardTestFiles: true,
passed: true,
specs: mobileSpecs

@@ -40,14 +44,14 @@ },

name: 'iPad',
appiumVersion: '1.6.0',
appiumVersion: '1.6.3',
browserName: 'Safari',
deviceName: 'iPad Simulator',
deviceName: 'iPad Air 2 Simulator',
deviceOrientation: 'portrait',
platformName: 'iOS',
platformVersion: '10.0',
logName: 'iPad Air 2 Simulator Safari',
username: sauceUsername,
accessKey: sauceAccessKey,
build: travisBuild,
'tunnel-identifier': travisBuild,
username: SAUCE_USERNAME,
accessKey: SAUCE_ACCESS_KEY,
build: TRAVIS_JOB_ID,
'tunnel-identifier': TRAVIS_JOB_ID,
shardTestFiles: true,
passed: true,
specs: mobileSpecs

@@ -60,28 +64,26 @@ },

version: 'latest',
logName: 'Chrome latest',
logName: 'Chrome ',
screenResolution: '1400x1050',
username: sauceUsername,
accessKey: sauceAccessKey,
build: travisBuild,
'tunnel-identifier': travisBuild,
username: SAUCE_USERNAME,
accessKey: SAUCE_ACCESS_KEY,
build: TRAVIS_JOB_ID,
'tunnel-identifier': TRAVIS_JOB_ID,
shardTestFiles: true,
passed: true,
specs: desktopSpecs
},
// {
// name: 'Firefox',
// browserName: 'firefox',
// platform: 'Windows 10',
// version: 'latest',
// logName: 'Firefox ',
// screenResolution: '1400x1050',
// username: SAUCE_USERNAME,
// accessKey: SAUCE_ACCESS_KEY,
// build: TRAVIS_JOB_ID,
// 'tunnel-identifier': TRAVIS_JOB_ID,
// shardTestFiles: true,
// specs: desktopSpecs
// },
{
name: 'Firefox',
browserName: 'firefox',
platform: 'Windows 10',
version: 'latest',
logName: 'Firefox latest',
screenResolution: '1400x1050',
username: sauceUsername,
accessKey: sauceAccessKey,
build: travisBuild,
'tunnel-identifier': travisBuild,
shardTestFiles: true,
passed: true,
specs: desktopSpecs
},
{
name: 'Internet Explorer',

@@ -91,10 +93,9 @@ browserName: 'internet explorer',

version: '11.0',
logName: 'Internet Explorer 11',
logName: 'IE ',
screenResolution: '1400x1050',
username: sauceUsername,
accessKey: sauceAccessKey,
build: travisBuild,
'tunnel-identifier': travisBuild,
username: SAUCE_USERNAME,
accessKey: SAUCE_ACCESS_KEY,
build: TRAVIS_JOB_ID,
'tunnel-identifier': TRAVIS_JOB_ID,
shardTestFiles: true,
passed: true,
specs: desktopSpecs

@@ -107,10 +108,9 @@ },

version: 'latest',
logName: 'Microsoft Edge latest',
logName: 'Microsoft Edge ',
screenResolution: '1400x1050',
username: sauceUsername,
accessKey: sauceAccessKey,
build: travisBuild,
'tunnel-identifier': travisBuild,
username: SAUCE_USERNAME,
accessKey: SAUCE_ACCESS_KEY,
build: TRAVIS_JOB_ID,
'tunnel-identifier': TRAVIS_JOB_ID,
shardTestFiles: true,
passed: true,
specs: desktopSpecs

@@ -123,10 +123,9 @@ },

version: '9',
logName: 'Safari 9',
logName: 'Safari #1 ',
screenResolution: '1600x1200',
username: sauceUsername,
accessKey: sauceAccessKey,
build: travisBuild,
'tunnel-identifier': travisBuild,
username: SAUCE_USERNAME,
accessKey: SAUCE_ACCESS_KEY,
build: TRAVIS_JOB_ID,
'tunnel-identifier': TRAVIS_JOB_ID,
shardTestFiles: true,
passed: true,
specs: desktopSpecs

@@ -139,10 +138,9 @@ },

version: '10',
logName: 'Safari 10',
logName: 'Safari #2 ',
screenResolution: '1600x1200',
username: sauceUsername,
accessKey: sauceAccessKey,
build: travisBuild,
'tunnel-identifier': travisBuild,
username: SAUCE_USERNAME,
accessKey: SAUCE_ACCESS_KEY,
build: TRAVIS_JOB_ID,
'tunnel-identifier': TRAVIS_JOB_ID,
shardTestFiles: true,
passed: true,
specs: desktopSpecs

@@ -152,2 +150,23 @@ }

config.onComplete = function () {
return browser.getSession().then(session => {
JOB_ID = session.getId();
});
};
config.onCleanUp = function (exitCode) {
const saucelabs = new SauceLabs({
username: SAUCE_USERNAME,
password: SAUCE_ACCESS_KEY
});
return new Promise((resolve, reject) => {
saucelabs.updateJob(JOB_ID, {
passed: exitCode === 0
},
() => resolve(),
error => reject('Error:', error));
});
};
exports.config = config;

@@ -48,4 +48,5 @@ 'use strict';

browser.testConfig = testConfig;
browser.isChrome = testConfig.browserName === 'chrome';
});
}
};

@@ -19,7 +19,7 @@ 'use strict';

blockOut : [{x: 0, y: 0, width: 750, height: 40}],
name:'iPhoneSimulator-safari-750x1334-dpr-2'
name:'iPhone6Simulator-safari-750x1334-dpr-2'
},
iPad: {
blockOut : [{x: 0, y: 0, width: 1536, height: 40}],
name:'iPadSimulator-safari-1536x2048-dpr-2'
name:'iPadAir2Simulator-safari-1536x2048-dpr-2'
}

@@ -26,0 +26,0 @@ };

@@ -36,2 +36,5 @@ 'use strict';

expect(PixDiff.RESULT_IDENTICAL).to.equal(5);
expect(PixDiff.OUTPUT_DIFFERENT).to.equal(10);
expect(PixDiff.OUTPUT_SIMILAR).to.equal(20);
expect(PixDiff.OUTPUT_ALL).to.equal(100);
});

@@ -38,0 +41,0 @@ });