Comparing version 1.0.10 to 1.0.11
Changelog | ||
========= | ||
v1.0.11 - Merged PR #19 to add cucumber support | ||
v1.0.10 - Fix not resolving path to framework during initialisation #14 | ||
@@ -4,0 +6,0 @@ - Update dependencies |
@@ -12,5 +12,4 @@ 'use strict'; | ||
src: [ | ||
"test/screenshots/*", | ||
"!test/screenshots/exampleFail*.png", | ||
"test/screenshots/diff/*.png" | ||
'test/screenshots/*', | ||
'!test/screenshots/exampleFail*.png' | ||
] | ||
@@ -20,3 +19,17 @@ } | ||
jshint: { | ||
all: ['index.js', 'test/**/*.spec.js', 'test/**/*.steps.js'], | ||
options: { | ||
jshintrc: '.jshintrc', | ||
ignores: ['node_modules/', 'framework/'] | ||
} | ||
}, | ||
run: { | ||
cucumber: { | ||
cmd: 'node_modules/.bin/protractor', | ||
args: [ | ||
'test/protractorCucumber.conf.js' | ||
] | ||
}, | ||
jasmine: { | ||
@@ -53,6 +66,8 @@ cmd: 'node_modules/.bin/protractor', | ||
//tasks | ||
grunt.registerTask('cucumber', 'Run cucumber integration tests', ['clean:screens', 'run:cucumber']); | ||
grunt.registerTask('jasmine', 'Run Jasmine integration tests', ['clean:screens', 'run:jasmine']); | ||
grunt.registerTask('mocha', 'Run Mocha integration tests', ['clean:screens', 'run:mocha']); | ||
grunt.registerTask('build', ['jshint:all']); | ||
grunt.registerTask('release', ['bump']); | ||
grunt.registerTask('default', ['jasmine', 'mocha']); | ||
grunt.registerTask('default', ['jasmine', 'mocha', 'cucumber']); | ||
}; |
149
index.js
@@ -1,6 +0,7 @@ | ||
var blinkDiff = require('blink-diff'), | ||
pngImage = require('png-image'), | ||
'use strict'; | ||
var BlinkDiff = require('blink-diff'), | ||
PngImage = require('png-image'), | ||
assert = require('assert'), | ||
path = require('path'), | ||
util = require('util'), | ||
fs = require('fs'), | ||
@@ -18,13 +19,17 @@ camelCase = require('camel-case'); | ||
* @param {string} options.height Height of browser | ||
* @param {string} options.formatImageOptions Custom variables for Image Name | ||
* @param {string} options.formatImageName Custom format image name | ||
* | ||
* @property {string} _basePath | ||
* @property {int} _width | ||
* @property {int} _height | ||
* @property {object} _capabilities | ||
* @property {webdriver|promise} _flow | ||
* @property {string} basePath | ||
* @property {int} width | ||
* @property {int} height | ||
* @property {string} formatOptions | ||
* @property {string} formatString | ||
* @property {object} capabilities | ||
* @property {webdriver|promise} flow | ||
* @property {int} devicePixelRatio | ||
*/ | ||
function PixDiff(options) { | ||
this._basePath = options.basePath; | ||
assert.ok(options.basePath, "Image base path not given."); | ||
this.basePath = options.basePath; | ||
assert.ok(options.basePath, 'Image base path not given.'); | ||
@@ -35,11 +40,14 @@ if (!fs.existsSync(options.basePath + '/diff') || !fs.statSync(options.basePath + '/diff').isDirectory()) { | ||
this._width = options.width || 1280; | ||
this._height = options.height || 1024; | ||
this.width = options.width || 1280; | ||
this.height = options.height || 1024; | ||
this._formatString = options.formatImageName || "{tag}-{browserName}-{width}x{height}"; | ||
this.formatOptions = options.formatImageOptions || {}; | ||
this.formatString = options.formatImageName || '{tag}-{browserName}-{width}x{height}'; | ||
this._flow = browser.controlFlow(); | ||
this.flow = browser.controlFlow(); | ||
this.devicePixelRatio = 1; | ||
// init | ||
browser.driver.manage().window().setSize(this._width, this._height) | ||
browser.driver.manage().window().setSize(this.width, this.height) | ||
.then(function () { | ||
@@ -49,6 +57,12 @@ return browser.getProcessedConfig(); | ||
.then(function (data) { | ||
this._capabilities = data.capabilities; | ||
assert.ok(this._capabilities.browserName, "Browser name is undefined."); | ||
// Require PixDiff matchers | ||
require(path.resolve(__dirname, 'framework', data.framework)); | ||
this.capabilities = data.capabilities; | ||
assert.ok(this.capabilities.browserName, 'Browser name is undefined.'); | ||
// Require PixDiff matchers for jasmine(2)/mocha | ||
if (data.framework !== 'custom') { | ||
require(path.resolve(__dirname, 'framework', data.framework)); | ||
} | ||
return browser.driver.executeScript('return window.devicePixelRatio;'); | ||
}.bind(this)) | ||
.then(function (ratio) { | ||
this.devicePixelRatio = Math.floor(ratio); | ||
}.bind(this)); | ||
@@ -62,3 +76,3 @@ } | ||
* | ||
* @method _mergeDefaultOptions | ||
* @method mergeDefaultOptions | ||
* @param {object} optionsA | ||
@@ -69,10 +83,10 @@ * @param {object} optionsB | ||
*/ | ||
_mergeDefaultOptions: function(optionsA, optionsB) { | ||
mergeDefaultOptions: function (optionsA, optionsB) { | ||
optionsB = (typeof optionsB === 'object') ? optionsB : {}; | ||
for (var option in optionsB) { | ||
Object.keys(optionsB).forEach(function (option) { | ||
if (!optionsA.hasOwnProperty(option)) { | ||
optionsA[option] = optionsB[option]; | ||
} | ||
} | ||
}); | ||
return optionsA; | ||
@@ -84,3 +98,3 @@ }, | ||
* | ||
* @method _format | ||
* @method format | ||
* @param {string} formatString | ||
@@ -91,13 +105,15 @@ * @param {string} description | ||
*/ | ||
_format: function(formatString, description) { | ||
var formatOptions = { | ||
format: function (formatString, description) { | ||
var defaults = { | ||
'tag': camelCase(description), | ||
'browserName': this._capabilities.browserName, | ||
'width': this._width, | ||
'height': this._height | ||
'browserName': this.capabilities.browserName, | ||
'width': this.width, | ||
'height': this.height | ||
}; | ||
for (var option in formatOptions ) { | ||
formatString = formatString.replace('{' + option + '}', formatOptions[option]); | ||
} | ||
defaults = this.mergeDefaultOptions(defaults, this.formatOptions); | ||
Object.keys(defaults).forEach(function (option) { | ||
formatString = formatString.replace('{' + option + '}', defaults[option]); | ||
}); | ||
return formatString + '.png'; | ||
@@ -116,9 +132,9 @@ }, | ||
*/ | ||
saveScreen: function(tag) { | ||
return this._flow.execute(function() { | ||
saveScreen: function (tag) { | ||
return this.flow.execute(function () { | ||
return browser.takeScreenshot() | ||
.then(function(image) { | ||
return new pngImage({ | ||
.then(function (image) { | ||
return new PngImage({ | ||
imagePath: new Buffer(image, 'base64'), | ||
imageOutputPath: path.join(this._basePath, this._format(this._formatString, tag)) | ||
imageOutputPath: path.join(this.basePath, this.format(this.formatString, tag)) | ||
}).runWithPromise(); | ||
@@ -140,20 +156,25 @@ }.bind(this)); | ||
*/ | ||
saveRegion: function(element, tag) { | ||
saveRegion: function (element, tag) { | ||
var size, | ||
rect; | ||
return this._flow.execute(function() { | ||
return this.flow.execute(function () { | ||
return element.getSize() | ||
.then(function(elementSize) { | ||
.then(function (elementSize) { | ||
size = elementSize; | ||
return element.getLocation(); | ||
}) | ||
.then(function(point) { | ||
.then(function (point) { | ||
rect = {height: size.height, width: size.width, x: Math.floor(point.x), y: Math.floor(point.y)}; | ||
return browser.takeScreenshot(); | ||
}) | ||
.then(function(image) { | ||
return new pngImage({ | ||
.then(function (image) { | ||
if (this.devicePixelRatio > 1) { | ||
Object.keys(rect).forEach(function (item) { | ||
rect[item] *= this.devicePixelRatio; | ||
}.bind(this)); | ||
} | ||
return new PngImage({ | ||
imagePath: new Buffer(image, 'base64'), | ||
imageOutputPath: path.join(this._basePath, this._format(this._formatString, tag)), | ||
imageOutputPath: path.join(this.basePath, this.format(this.formatString, tag)), | ||
cropImage: rect | ||
@@ -177,18 +198,18 @@ }).runWithPromise(); | ||
*/ | ||
checkScreen: function(tag, options) { | ||
checkScreen: function (tag, options) { | ||
var defaults; | ||
return this._flow.execute(function() { | ||
return this.flow.execute(function () { | ||
return browser.takeScreenshot() | ||
.then(function(image) { | ||
tag = this._format(this._formatString, tag); | ||
.then(function (image) { | ||
tag = this.format(this.formatString, tag); | ||
defaults = { | ||
imageAPath: path.join(this._basePath, tag), | ||
imageAPath: path.join(this.basePath, tag), | ||
imageB: new Buffer(image, 'base64'), | ||
imageOutputPath: path.join(this._basePath, 'diff', path.basename(tag)), | ||
imageOutputLimit: blinkDiff.OUTPUT_DIFFERENT | ||
imageOutputPath: path.join(this.basePath, 'diff', path.basename(tag)), | ||
imageOutputLimit: BlinkDiff.OUTPUT_DIFFERENT | ||
}; | ||
return new blinkDiff(this._mergeDefaultOptions(defaults, options)).runWithPromise(); | ||
return new BlinkDiff(this.mergeDefaultOptions(defaults, options)).runWithPromise(); | ||
}.bind(this)) | ||
.then(function(result) { | ||
.then(function (result) { | ||
return result; | ||
@@ -212,3 +233,3 @@ }); | ||
*/ | ||
checkRegion: function(element, tag, options) { | ||
checkRegion: function (element, tag, options) { | ||
var size, | ||
@@ -218,24 +239,24 @@ rect, | ||
return this._flow.execute(function() { | ||
return this.flow.execute(function () { | ||
return element.getSize() | ||
.then(function(elementSize) { | ||
.then(function (elementSize) { | ||
size = elementSize; | ||
return element.getLocation(); | ||
}) | ||
.then(function(point) { | ||
.then(function (point) { | ||
rect = {height: size.height, width: size.width, x: Math.floor(point.x), y: Math.floor(point.y)}; | ||
return browser.takeScreenshot(); | ||
}) | ||
.then(function(image) { | ||
tag = this._format(this._formatString, tag); | ||
.then(function (image) { | ||
tag = this.format(this.formatString, tag); | ||
defaults = { | ||
imageAPath: path.join(this._basePath, tag), | ||
imageAPath: path.join(this.basePath, tag), | ||
imageB: new Buffer(image, 'base64'), | ||
imageOutputPath: path.join(this._basePath, 'diff', path.basename(tag)), | ||
imageOutputLimit: blinkDiff.OUTPUT_DIFFERENT, | ||
imageOutputPath: path.join(this.basePath, 'diff', path.basename(tag)), | ||
imageOutputLimit: BlinkDiff.OUTPUT_DIFFERENT, | ||
cropImageB: rect | ||
}; | ||
return new blinkDiff(this._mergeDefaultOptions(defaults, options)).runWithPromise(); | ||
return new BlinkDiff(this.mergeDefaultOptions(defaults, options)).runWithPromise(); | ||
}.bind(this)) | ||
.then(function(result) { | ||
.then(function (result) { | ||
return result; | ||
@@ -242,0 +263,0 @@ }); |
{ | ||
"name": "pix-diff", | ||
"version": "1.0.10", | ||
"version": "1.0.11", | ||
"description": "Protractor plugin for image comparison", | ||
"main": "index.js", | ||
"dependencies": { | ||
"blink-diff": "1.0.7", | ||
"blink-diff": "1.0.12", | ||
"png-image": "1.0.1", | ||
@@ -14,2 +14,3 @@ "camel-case": "1.2.2" | ||
"chai-as-promised": "^5.3.0", | ||
"cucumber": "^1.2.2", | ||
"grunt": "^1.0.1", | ||
@@ -19,6 +20,9 @@ "grunt-bump": "^0.8.0", | ||
"grunt-contrib-clean": "^1.0.0", | ||
"grunt-contrib-jshint": "^1.0.0", | ||
"grunt-run": "^0.6.0", | ||
"jshint": "^2.9.2", | ||
"load-grunt-tasks": "^3.5.0", | ||
"mocha": "^2.4.5", | ||
"protractor": "3.2.2" | ||
"protractor": "^3.2.2", | ||
"protractor-cucumber-framework": "^0.6.0" | ||
}, | ||
@@ -25,0 +29,0 @@ "scripts": { |
@@ -35,3 +35,3 @@ Pix-Diff | ||
var PixDiff = require('pix-diff'); | ||
browser.pixdiff = new PixDiff( | ||
browser.pixDiff = new PixDiff( | ||
{ | ||
@@ -48,2 +48,3 @@ basePath: 'path/to/screenshots/', | ||
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. | ||
PixDiff can also work with Cucumber.js. There are no comparison methods provided for Cucumber.js because Cucumber.js doesn't have its own ```expect``` methods. | ||
@@ -59,3 +60,3 @@ **Jasmine Example:** | ||
it("should match the page", function () { | ||
expect(browser.pixdiff.checkScreen('examplePage')).toMatchScreen(); | ||
expect(browser.pixDiff.checkScreen('examplePage')).toMatchScreen(); | ||
}); | ||
@@ -65,11 +66,11 @@ | ||
element(By.buttonText('yes')).click(); | ||
expect(browser.pixdiff.checkScreen('examplePage')).not.toMatchScreen(); | ||
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(); | ||
@@ -80,2 +81,49 @@ }); | ||
**Cucumber Example:** | ||
```javascript | ||
var chai = require('chai'), | ||
chaiAsPromised = require('chai-as-promised'); | ||
chai.use(chaiAsPromised); | ||
var expect = chai.expect; | ||
function CucumberSteps() { | ||
this.Given(/^I load the url$/, function () { | ||
return browser.get('http://www.example.com/'); | ||
}); | ||
this.Then(/^Pix\-Diff should match the page$/, function () { | ||
return browser.pixDiff.checkScreen('examplePage') | ||
.then(function (result) { | ||
return expect(result.differences).to.equal(0); | ||
}); | ||
}); | ||
this.Then(/^Pix\-Diff should not match the page$/, function () { | ||
element(By.buttonText('yes')).click(); | ||
return browser.pixDiff.checkScreen('examplePage') | ||
.then(function (result) { | ||
return expect(result.differences).to.not.equal(0); | ||
}); | ||
}); | ||
this.Then(/^Pix\-Diff should match the title$/, function () { | ||
return browser.pixDiff.checkRegion(element(By.id('title')), 'example page title') | ||
.then(function (result) { | ||
return expect(result.differences).to.equal(0); | ||
}); | ||
}); | ||
this.Then(/^Pix\-Diff should match the title with blockout$/, function () { | ||
return browser.pixDiff.checkRegion(element(By.id('title')), 'example page title', { | ||
blockOut: [{x: 10, y: 132, width: 100, height: 50}]}) | ||
.then(function (result) { | ||
return expect(result.differences).to.equal(0); | ||
}); | ||
}); | ||
} | ||
module.exports = CucumberSteps; | ||
``` | ||
####PixDiff Parameters: | ||
@@ -134,11 +182,16 @@ | ||
Todo | ||
todo | ||
##Tests | ||
Run the tests with the following command: | ||
Run all tests with the following command: | ||
```shell | ||
npm run test | ||
npm test | ||
``` | ||
Run all tests by framework: | ||
```shell | ||
npm test -- jasmine/mocha/cucumber | ||
``` | ||
###Dependencies | ||
@@ -159,2 +212,4 @@ * [blink-diff](https://github.com/yahoo/blink-diff) | ||
* [chai-as-promised](https://github.com/domenic/chai-as-promised) | ||
* [cucumber](https://github.com/cucumber/cucumber-js) | ||
* [protractor-cucumber-framework](https://github.com/mattfritz/protractor-cucumber-framework) | ||
@@ -165,2 +220,2 @@ ##License | ||
Copyright 2016 Koola. | ||
Copyright 2016 Koola. |
'use strict'; | ||
var BlinkDiff = require('blink-diff'), | ||
fs = require('fs'); | ||
fs = require('fs'), | ||
PixDiff = require('../'); | ||
describe("Pix-Diff", function() { | ||
describe('Pix-Diff', function() { | ||
beforeEach(function() { | ||
beforeEach(function () { | ||
browser.get(browser.baseUrl); | ||
}); | ||
it("should save the screen", function () { | ||
var tagName = 'examplePage'; | ||
describe('mathod matchers', function() { | ||
browser.pixDiff.saveScreen(tagName).then(function() { | ||
expect(fs.existsSync(__dirname + '/screenshots/' + tagName + '-chrome-800x600.png')).toBe(true); | ||
beforeEach(function () { | ||
browser.pixDiff = new PixDiff({ | ||
basePath: 'test/screenshots', | ||
width: 800, | ||
height: 600 | ||
}); | ||
}); | ||
}); | ||
it("should match the page", function () { | ||
browser.pixDiff.checkScreen('example-page').then(function(result) { | ||
expect(result.code).toEqual(BlinkDiff.RESULT_IDENTICAL); | ||
it('should save the screen', function () { | ||
var tagName = 'examplePage'; | ||
browser.pixDiff.saveScreen(tagName).then(function () { | ||
expect(fs.existsSync(__dirname + '/screenshots/' + tagName + '-chrome-800x600.png')).toBe(true); | ||
}); | ||
}); | ||
}); | ||
it("should match the page with custom matcher", function () { | ||
expect(browser.pixDiff.checkScreen('example-page')).toMatchScreen(); | ||
}); | ||
it('should save the screen region', function () { | ||
var tagName = 'examplePageRegion'; | ||
it("should not match the page", function () { | ||
browser.pixDiff.checkScreen('example-fail', {threshold:1}).then(function(result) { | ||
expect(result.code).toEqual(BlinkDiff.RESULT_DIFFERENT); | ||
browser.pixDiff.saveRegion(element(by.css('div h1')), tagName).then(function () { | ||
expect(fs.existsSync(__dirname + '/screenshots/' + tagName + '-chrome-800x600.png')).toBe(true); | ||
}); | ||
}); | ||
it('should match the page', function () { | ||
browser.pixDiff.checkScreen('examplePage').then(function (result) { | ||
expect(result.code).toEqual(BlinkDiff.RESULT_IDENTICAL); | ||
}); | ||
}); | ||
it('should match the page with custom matcher', function () { | ||
expect(browser.pixDiff.checkScreen('examplePage')).toMatchScreen(); | ||
}); | ||
it('should not match the page', function () { | ||
browser.pixDiff.checkScreen('example-fail', {threshold: 1}).then(function (result) { | ||
expect(result.code).toEqual(BlinkDiff.RESULT_DIFFERENT); | ||
}); | ||
}); | ||
it('should not match the page with custom matcher', function () { | ||
expect(browser.pixDiff.checkScreen('exampleFail', {threshold: 1})).not.toMatchScreen(); | ||
}); | ||
it('should not crash with image not found', function () { | ||
var errorThrown = false; | ||
browser.pixDiff.checkScreen('imagenotexst', {threshold: 1}).then(function () { | ||
fail('must not do a comparison.'); | ||
}).catch(function () { | ||
// good | ||
errorThrown = true; | ||
}).then(function () { | ||
expect(errorThrown).toBe(true); | ||
}); | ||
}); | ||
}); | ||
it("should not match the page with custom matcher", function () { | ||
expect(browser.pixDiff.checkScreen('example-fail', {threshold:1})).not.toMatchScreen(); | ||
describe('format image name', function() { | ||
beforeEach(function () { | ||
browser.pixDiff = new PixDiff({ | ||
basePath: 'test/screenshots', | ||
width: 800, | ||
height: 600, | ||
formatImageOptions: {'env': 'TEST'}, | ||
formatImageName: '{env}_{tag}_{browserName}_{width}-{height}' | ||
}); | ||
}); | ||
it('should save screen with formatted basename', function () { | ||
var tagName = 'customName'; | ||
browser.pixDiff.saveScreen(tagName).then(function () { | ||
expect(fs.existsSync(__dirname + '/screenshots/TEST_' + tagName + '_chrome_800-600.png')).toBe(true); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
@@ -5,5 +5,6 @@ 'use strict'; | ||
blinkDiff = require('blink-diff'), | ||
fs = require('fs'); | ||
fs = require('fs'), | ||
PixDiff = require('../'); | ||
describe("Pix-Diff", function() { | ||
describe('Pix-Diff', function() { | ||
@@ -14,29 +15,81 @@ beforeEach(function () { | ||
it("should save the screen", function () { | ||
var tagName = 'examplePageMocha'; | ||
describe('method matchers', function() { | ||
browser.pixDiff.saveScreen(tagName).then(function () { | ||
expect(fs.existsSync(__dirname + '/screenshots/' + tagName + '-chrome-800x600.png')).to.be.true; | ||
beforeEach(function () { | ||
browser.pixDiff = new PixDiff({ | ||
basePath: 'test/screenshots', | ||
width: 800, | ||
height: 600 | ||
}); | ||
}); | ||
}); | ||
it("should match the page", function () { | ||
browser.pixDiff.checkScreen('example-page-mocha').then(function(result) { | ||
expect(result.code).to.equal(blinkDiff.RESULT_IDENTICAL); | ||
it('should save the screen', function () { | ||
var tagName = 'examplePageMocha'; | ||
browser.pixDiff.saveScreen(tagName).then(function () { | ||
expect(fs.existsSync(__dirname + '/screenshots/' + tagName + '-chrome-800x600.png')).to.be.true; | ||
}); | ||
}); | ||
}); | ||
it("should match the page with custom matcher", function () { | ||
expect(browser.pixDiff.checkScreen('example-page-mocha')).to.matchScreen(); | ||
}); | ||
it('should save the screen region', function () { | ||
var tagName = 'examplePageRegionMocha'; | ||
it("should not match the page", function () { | ||
browser.pixDiff.checkScreen('example-fail', {threshold:1}).then(function(result) { | ||
expect(result.code).to.equal(blinkDiff.RESULT_DIFFERENT); | ||
browser.pixDiff.saveRegion(element(by.css('div h1')), tagName).then(function () { | ||
expect(fs.existsSync(__dirname + '/screenshots/' + tagName + '-chrome-800x600.png')).to.be.true; | ||
}); | ||
}); | ||
it('should match the page', function () { | ||
browser.pixDiff.checkScreen('example-page-mocha').then(function (result) { | ||
expect(result.code).to.equal(blinkDiff.RESULT_IDENTICAL); | ||
}); | ||
}); | ||
it('should match the page with custom matcher', function () { | ||
expect(browser.pixDiff.checkScreen('example-page-mocha')).to.matchScreen(); | ||
}); | ||
it('should not match the page', function () { | ||
browser.pixDiff.checkScreen('example-fail', {threshold: 1}).then(function (result) { | ||
expect(result.code).to.equal(blinkDiff.RESULT_DIFFERENT); | ||
}); | ||
}); | ||
it('should not match the page with custom matcher', function () { | ||
expect(browser.pixDiff.checkScreen('example-fail', {threshold: 1})).not.to.matchScreen(); | ||
}); | ||
it('should not crash with image not found', function () { | ||
var errorThrown = false; | ||
browser.pixDiff.checkScreen('imagenotexst', {threshold: 1}).then(function () { | ||
expect.fail(); | ||
}).catch(function () { | ||
// good | ||
errorThrown = true; | ||
}).then(function () { | ||
expect(errorThrown).to.be.true; | ||
}); | ||
}); | ||
}); | ||
it("should not match the page with custom matcher", function () { | ||
expect(browser.pixDiff.checkScreen('example-fail', {threshold:1})).not.to.matchScreen(); | ||
describe('format image name', function() { | ||
beforeEach(function () { | ||
browser.pixDiff = new PixDiff({ | ||
basePath: 'test/screenshots', | ||
width: 800, | ||
height: 600, | ||
formatImageOptions: {'env': 'TEST'}, | ||
formatImageName: '{env}_{tag}_{browserName}_{width}-{height}' | ||
}); | ||
}); | ||
it('should save screen with formatted basename', function () { | ||
var tagName = 'customName'; | ||
browser.pixDiff.saveScreen(tagName).then(function () { | ||
expect(fs.existsSync(__dirname + '/screenshots/TEST_' + tagName + '_chrome_800-600.png')).to.be.true; | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
@@ -21,9 +21,2 @@ 'use strict'; | ||
onPrepare: function() { | ||
var PixDiff = require('../'); | ||
browser.pixDiff = new PixDiff({ | ||
basePath: 'test/screenshots', | ||
width: 800, | ||
height: 600 | ||
}); | ||
browser.ignoreSynchronization = true; | ||
@@ -30,0 +23,0 @@ }, |
@@ -21,12 +21,5 @@ 'use strict'; | ||
onPrepare: function() { | ||
var chai = require('chai').use(require('chai-as-promised')); | ||
var chai = require('chai'); | ||
chai.config.truncateThreshold = 0; | ||
var PixDiff = require('../'); | ||
browser.pixDiff = new PixDiff({ | ||
basePath: 'test/screenshots', | ||
width: 800, | ||
height: 600 | ||
}); | ||
browser.ignoreSynchronization = true; | ||
@@ -33,0 +26,0 @@ }, |
Sorry, the diff of this file is not supported yet
39520
19
624
214
14
5
+ Addedajv@6.12.6(transitive)
+ Addedasn1@0.2.6(transitive)
+ Addedassert-plus@1.0.0(transitive)
+ Addedasynckit@0.4.0(transitive)
+ Addedaws-sign2@0.7.0(transitive)
+ Addedaws4@1.13.2(transitive)
+ Addedbcrypt-pbkdf@1.0.2(transitive)
+ Addedblink-diff@1.0.12(transitive)
+ Addedcaseless@0.12.0(transitive)
+ Addedcombined-stream@1.0.8(transitive)
+ Addedcore-util-is@1.0.2(transitive)
+ Addeddashdash@1.14.1(transitive)
+ Addeddelayed-stream@1.0.0(transitive)
+ Addedecc-jsbn@0.1.2(transitive)
+ Addedextend@3.0.2(transitive)
+ Addedextsprintf@1.3.0(transitive)
+ Addedfast-deep-equal@3.1.3(transitive)
+ Addedfast-json-stable-stringify@2.1.0(transitive)
+ Addedforever-agent@0.6.1(transitive)
+ Addedform-data@2.3.3(transitive)
+ Addedgetpass@0.1.7(transitive)
+ Addedhar-schema@2.0.0(transitive)
+ Addedhar-validator@5.1.5(transitive)
+ Addedhttp-signature@1.2.0(transitive)
+ Addediconv-lite@0.4.24(transitive)
+ Addedis-typedarray@1.0.0(transitive)
+ Addedisstream@0.1.2(transitive)
+ Addedjsbn@0.1.1(transitive)
+ Addedjson-schema@0.4.0(transitive)
+ Addedjson-schema-traverse@0.4.1(transitive)
+ Addedjson-stringify-safe@5.0.1(transitive)
+ Addedjsprim@1.4.2(transitive)
+ Addedmime-db@1.52.0(transitive)
+ Addedmime-types@2.1.35(transitive)
+ Addedoauth-sign@0.9.0(transitive)
+ Addedpako@0.2.9(transitive)
+ Addedperformance-now@2.1.0(transitive)
+ Addedpngjs-image@0.11.7(transitive)
+ Addedpsl@1.15.0(transitive)
+ Addedpunycode@2.3.1(transitive)
+ Addedqs@6.5.3(transitive)
+ Addedrequest@2.88.2(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedsafer-buffer@2.1.2(transitive)
+ Addedsshpk@1.18.0(transitive)
+ Addedtough-cookie@2.5.0(transitive)
+ Addedtunnel-agent@0.6.0(transitive)
+ Addedtweetnacl@0.14.5(transitive)
+ Addeduri-js@4.4.1(transitive)
+ Addeduuid@3.4.0(transitive)
+ Addedverror@1.10.0(transitive)
- Removedblink-diff@1.0.7(transitive)
- Removedpngjs@0.4.0(transitive)
- Removedpngjs-image@0.9.3(transitive)
Updatedblink-diff@1.0.12