From 6539f9d9c36f34b607652346da2698d68f8b1eaf Mon Sep 17 00:00:00 2001 From: Niklas von Hertzen Date: Sun, 6 Dec 2015 13:32:35 -0500 Subject: [PATCH] Fix webdriver tests for node 4.0 --- package.json | 7 +++++-- tests/sauceconnect.js | 13 +++++++++++++ tests/selenium.js | 16 +++++++++++----- 3 files changed, 29 insertions(+), 7 deletions(-) create mode 100644 tests/sauceconnect.js diff --git a/package.json b/package.json index b88c376..0784ae1 100644 --- a/package.json +++ b/package.json @@ -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" diff --git a/tests/sauceconnect.js b/tests/sauceconnect.js new file mode 100644 index 0000000..9000689 --- /dev/null +++ b/tests/sauceconnect.js @@ -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'); +}); diff --git a/tests/selenium.js b/tests/selenium.js index 678b98f..cc4440a 100644 --- a/tests/selenium.js +++ b/tests/selenium.js @@ -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) {