Fix webdriver tests for node 4.0

This commit is contained in:
Niklas von Hertzen 2015-12-06 13:32:35 -05:00
parent 3cb0911de3
commit 6539f9d9c3
3 changed files with 29 additions and 7 deletions

View File

@ -35,12 +35,15 @@
"html2canvas-proxy": "0.0.5",
"humanize-duration": "^2.0.1",
"lodash": "^3.10.1",
"png-js": "^0.1.1",
"pngjs": "^2.2.0",
"requirejs": "^2.1.20",
"sauce-connect-launcher": "^0.13.0",
"wd": "^0.4.0"
},
"scripts": {
"test": "grunt travis --verbose"
"test": "grunt travis --verbose",
"start": "grunt server",
"sauceconnect": "tests/sauceconnect.js"
},
"homepage": "http://html2canvas.hertzen.com",
"license": "MIT"

13
tests/sauceconnect.js Normal file
View File

@ -0,0 +1,13 @@
const sauceConnectLauncher = require('sauce-connect-launcher');
sauceConnectLauncher({
username: process.env.SAUCE_USERNAME,
accessKey: process.env.SAUCE_ACCESS_KEY,
logger: console.log
}, err => {
if (err) {
console.error(err.message);
return;
}
console.log('Sauce Connect ready');
});

View File

@ -6,7 +6,7 @@
url = require("url"),
path = require("path"),
base64_arraybuffer = require('base64-arraybuffer'),
PNG = require('png-js'),
PNG = require('pngjs').PNG,
Promise = require('bluebird'),
_ = require('lodash'),
humanizeDuration = require("humanize-duration"),
@ -20,9 +20,15 @@
var port = 8080;
function getPixelArray(base64) {
return new Promise(function(resolve) {
var arraybuffer = base64_arraybuffer.decode(base64);
(new PNG(arraybuffer)).decodePixels(resolve);
return new Promise(function(resolve, reject) {
const arraybuffer = base64_arraybuffer.decode(base64);
new PNG().parse(arraybuffer, (error, data) => {
if (error) {
reject(error);
} else {
resolve(data.data);
}
});
});
}
@ -78,7 +84,7 @@
return Promise.resolve(browser
.then(utils.loadTestPage(browser, test, port))
.then(captureScreenshots(browser))
.then(analyzeResults(test))).cancellable();
.then(analyzeResults(test)));
}
exports.tests = function(browsers, singleTest) {