Skip to content
This repository was archived by the owner on Dec 18, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
// "parser": "babel-eslint",
"root": true,
"extends": "eslint:recommended",
"rules": {
"strict": 0,
"quotes": [0, "single"],
"comma-dangle": 0,
"curly": [1, "multi-line"],
"no-console": 0,
"no-use-before-define": [1, "nofunc"],
"no-unused-vars": [1, {
"vars": "local",
"varsIgnorePattern": "^_"
}],
"no-underscore-dangle": 0,
"new-cap": 0,
"consistent-return": 0,
"camelcase": 0,
"dot-notation": 0,
"semi": [1, "always"],
},
env: {
// "es6": true,
"node": true
}
}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ pids
*.pid
*.seed

# Temp files
.tmp*

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

Expand Down
17 changes: 4 additions & 13 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,15 @@ language: node_js

node_js:
- '0.10'
- '0.12'
- '4'
- '5'

before_install:
- sudo apt-get update
- sudo apt-get install imagemagick graphicsmagick libcairo2-dev

before_script:
- "npm install -g bower http-server"
- "cd test/site && bower install && cd ../../"
- "curl -O http://selenium-release.storage.googleapis.com/2.43/selenium-server-standalone-2.43.1.jar"
- "java -jar selenium-server-standalone-2.43.1.jar -host 127.0.0.1 -port 4444 2>/dev/null 1>/dev/null &"
- "http-server -p 8080 &"
- "sleep 10"
- "if [[ $WEBDRIVERCSS_COVERAGE == '1' ]]; then ./node_modules/.bin/istanbul i lib -o lib-cov && cp lib/getPageInfo.js lib-cov && cp lib/makeScreenshot.js lib-cov && cp lib/documentScreenshot.js lib-cov && cp lib/viewportScreenshot.js lib-cov && cp lib/startSession.js lib-cov && cp lib/setScreenWidth.js lib-cov; fi"

script: "npm run-script travis"

after_script:
- "if [[ $WEBDRIVERCSS_COVERAGE == '1' ]]; then cat lcov.info | ./node_modules/coveralls/bin/coveralls.js; fi"
script: "npm test"

env:
matrix:
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## Release History

## 2.0.0beta-rc1 (2015-10-28)
* merged dev branch to make WebdriverCSS compatible with v3

## v1.1.10 (2015-12-19)
* Adjust scrolling to better support sticky headers (#131)
* Add option to tweak node-resemble-js image comparison (#121)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
WebdriverCSS [![Version](http://img.shields.io/badge/version-v1.1.10-brightgreen.svg)](https://www.npmjs.org/package/webdrivercss) [![Build Status](https://travis-ci.org/webdriverio/webdrivercss.png?branch=master)](https://travis-ci.org/webdriverio/webdrivercss) [![Coverage Status](https://coveralls.io/repos/webdriverio/webdrivercss/badge.png?branch=master)](https://coveralls.io/r/webdriverio/webdrivercss?branch=master) [![Join the chat at https://gitter.im/webdriverio/webdrivercss](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/webdriverio/webdrivercss?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
WebdriverCSS [![Version](http://img.shields.io/badge/version-v2.0.0beta-rc1-brightgreen.svg)](https://www.npmjs.org/package/webdrivercss) [![Build Status](https://travis-ci.org/webdriverio/webdrivercss.png?branch=master)](https://travis-ci.org/webdriverio/webdrivercss) [![Coverage Status](https://coveralls.io/repos/webdriverio/webdrivercss/badge.png?branch=master)](https://coveralls.io/r/webdriverio/webdrivercss?branch=master) [![Join the chat at https://gitter.im/webdriverio/webdrivercss](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/webdriverio/webdrivercss?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
============

---
Expand Down
69 changes: 36 additions & 33 deletions lib/asyncCallback.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,53 +4,56 @@
* run workflow again or execute callback function
*/

var workflow = require('./workflow.js'),
endSession = require('./endSession.js');
var endSession = require('./endSession.js');
var Promise = require('bluebird');

module.exports = function(err) {

var that = this;
var workflow = require('./workflow');
var ctx = this;

/**
* if error occured don't do another shot (if multiple screen width are set)
*/
/*istanbul ignore next*/
if(err) {
return this.cb(err);
}

/**
* on multiple screenWidth or multiple page elements
* repeat workflow
*/
if(this.screenWidth && this.screenWidth.length) {
if (err) return Promise.reject(err);
return Promise.try(function() {

/**
* if multiple screen widths are given
* start workflow all over again with same parameter
* on multiple screenWidth or multiple page elements
* repeat workflow
*/
this.queuedShots[0].screenWidth = this.screenWidth;
return workflow.call(this.self, this.pagename, this.queuedShots, this.cb);
if(ctx.screenWidth && ctx.screenWidth.length) {

/**
* if multiple screen widths are given
* start workflow all over again with same parameter
*/
ctx.queuedShots[0].screenWidth = ctx.screenWidth;
return workflow.call(ctx.self, ctx.pagename, ctx.queuedShots);

} else if (ctx.queuedShots.length > 1) {

} else if (this.queuedShots.length > 1) {
/**
* if multiple page modules are given
*/
return endSession.call(ctx)
.then(function() {
ctx.queuedShots.shift();
return workflow.call(ctx.self, ctx.pagename, ctx.queuedShots, ctx.cb);
});

}

/**
* if multiple page modules are given
* finish command
*/
return endSession.call(this, function() {
that.queuedShots.shift();
return workflow.call(that.self, that.pagename, that.queuedShots, that.cb);
return endSession.call(ctx)
.then(function() {
ctx.self.takeScreenshot = undefined;
return ctx.self.resultObject;
})
.finally(function() {
ctx.self.resultObject = {};
});

}

/**
* finish command
*/
return endSession.call(this, function(err) {
that.self.takeScreenshot = undefined;
that.cb(err, that.self.resultObject);
that.self.resultObject = {};
});

};
66 changes: 35 additions & 31 deletions lib/compareImages.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,42 @@
*/

var resemble = require('node-resemble-js');
var Promise = require('bluebird');

module.exports = function() {

/**
* need to find done function because gm doesn't have node like callbacks (err,res)
*/
var done = arguments[arguments.length - 1];

/**
* if there is no need for image comparison or no images gets saved on fs, just continue
*/
if(!this.isComparable || !this.self.saveImages) {
return done();
}

/**
* compare images
*/
var diff = resemble(this.baselinePath).compareTo(this.regressionPath);

/**
* map 'ignore' configuration to resemble options
*/
var ignore = this.currentArgs.ignore || "";
if (ignore.indexOf("color") === 0) {
diff.ignoreColors();
} else if (ignore.indexOf("antialias") === 0) {
diff.ignoreAntialiasing();
}

/**
* execute the comparison
*/
diff.onComplete(done.bind(null,null));
var ctx = this;

return Promise.try(function() {
/**
* if there is no need for image comparison or no images gets saved on fs, just continue
*/
if(!ctx.isComparable || !ctx.self.saveImages) {
return;
}

/**
* compare images
*/
var diff = resemble(ctx.baselinePath).compareTo(ctx.regressionPath);

/**
* map 'ignore' configuration to resemble options
*/
var ignore = ctx.currentArgs.ignore || "";
if (ignore.indexOf("color") === 0) {
diff.ignoreColors();
} else if (ignore.indexOf("antialias") === 0) {
diff.ignoreAntialiasing();
}

/**
* execute the comparison
*/
return new Promise(function(resolve, reject) {
diff.onComplete(function(res) { // this callback has bad arity
resolve(res);
});
});
});
};
Loading