From fca8eb5a38a90d8340af214235d92e5547f4ca09 Mon Sep 17 00:00:00 2001 From: Benaka Moorthi Date: Mon, 30 May 2016 15:31:04 -0700 Subject: [PATCH 1/7] Don't use es2015 preset since it requires using the generator-transform (in babel 6, the blacklist .babelrc property is no longer supported). --- .babelrc | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/.babelrc b/.babelrc index 9d8d516..e5d85e0 100644 --- a/.babelrc +++ b/.babelrc @@ -1 +1,24 @@ -{ "presets": ["es2015"] } +{ + "plugins": [ + "check-es2015-constants", + "transform-es2015-arrow-functions", + "transform-es2015-block-scoped-functions", + "transform-es2015-block-scoping", + "transform-es2015-classes", + "transform-es2015-computed-properties", + "transform-es2015-destructuring", + "transform-es2015-duplicate-keys", + "transform-es2015-for-of", + "transform-es2015-function-name", + "transform-es2015-literals", + "transform-es2015-modules-commonjs", + "transform-es2015-object-super", + "transform-es2015-parameters", + "transform-es2015-shorthand-properties", + "transform-es2015-spread", + "transform-es2015-sticky-regex", + "transform-es2015-template-literals", + "transform-es2015-typeof-symbol", + "transform-es2015-unicode-regex" + ] +} From d357310033715d59f8f50ee9692360bcd3d5b02d Mon Sep 17 00:00:00 2001 From: Benaka Moorthi Date: Mon, 30 May 2016 15:31:57 -0700 Subject: [PATCH 2/7] Remove loadTasks('build') call since it would try to load tasks in the files babel outputted if files were already built (resulting in error). Also process all files in the lib folder, not just the top level files. --- gruntfile.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/gruntfile.js b/gruntfile.js index be9bf99..f55dfe0 100644 --- a/gruntfile.js +++ b/gruntfile.js @@ -11,7 +11,7 @@ module.exports = function (grunt) { files: [{ expand: true, cwd: './lib', - src: ['*.js'], + src: ['**/*.js'], dest: 'build', ext: '.js' }] @@ -55,7 +55,6 @@ module.exports = function (grunt) { }) require('load-grunt-tasks')(grunt) - grunt.loadTasks('build') grunt.registerTask('default', ['build']) grunt.registerTask('build', 'Build grunt-webdriver', function () { grunt.task.run([ From a59e7f765f5f2198e707f08736fdfe6f1d874e0b Mon Sep 17 00:00:00 2001 From: Benaka Moorthi Date: Mon, 30 May 2016 15:36:30 -0700 Subject: [PATCH 3/7] Export documentScreenshot function as default export (this is what webdrivercss.js was importing it as). --- lib/documentScreenshot.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/documentScreenshot.js b/lib/documentScreenshot.js index 93cd926..59312c6 100644 --- a/lib/documentScreenshot.js +++ b/lib/documentScreenshot.js @@ -31,7 +31,7 @@ import getPageInfo from './scripts/getPageInfo' const CAPS_TAKING_FULLSIZE_SHOTS = ['firefox'] -export async function documentScreenshot (fileName) { +export default async function documentScreenshot (fileName) { let ErrorHandler = this.instance.ErrorHandler /*! From ebdeec4974b748ce8bb426b7aece132108d02ff3 Mon Sep 17 00:00:00 2001 From: Benaka Moorthi Date: Mon, 30 May 2016 15:37:29 -0700 Subject: [PATCH 4/7] Do not require ErrorHandler directly from the lib/... file in webdriverio since it will end up including the ES6 code, not the compiled code in webdriverio/build. --- lib/viewportScreenshot.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/viewportScreenshot.js b/lib/viewportScreenshot.js index cda4dd4..08f8e52 100644 --- a/lib/viewportScreenshot.js +++ b/lib/viewportScreenshot.js @@ -5,7 +5,7 @@ */ import gm from 'gm' -import ErrorHandler from 'webdriverio/lib/utils/ErrorHandler' +import { ErrorHandler } from 'webdriverio' import getScrollingPosition from './scripts/getScrollingPosition' import getScreenDimension from './scripts/getScreenDimension' From 2fd317b275bf491fbbeb6b5c3a4dae52c8fbc012 Mon Sep 17 00:00:00 2001 From: Benaka Moorthi Date: Mon, 30 May 2016 15:38:16 -0700 Subject: [PATCH 5/7] Add applitools default object to DEFAULT_PROPERTIES since it is assumed to exist by workflow.js and other files. --- lib/webdrivercss.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/webdrivercss.js b/lib/webdrivercss.js index 585eed4..03c46a3 100644 --- a/lib/webdrivercss.js +++ b/lib/webdrivercss.js @@ -13,7 +13,8 @@ const DEFAULT_PROPERTIES = { screenWidth: [], warning: [], resultObject: {}, - updateBaseline: false + updateBaseline: false, + applitools: {} } /** From 007cee37789d4434264b48a05c37c05562334e48 Mon Sep 17 00:00:00 2001 From: Benaka Moorthi Date: Mon, 30 May 2016 15:48:21 -0700 Subject: [PATCH 6/7] browser.end() does not take a callback, treat result as promise in tests' afterHook function. --- test/bootstrap.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/bootstrap.js b/test/bootstrap.js index 335921a..c675c72 100644 --- a/test/bootstrap.js +++ b/test/bootstrap.js @@ -31,7 +31,11 @@ afterHook = function(done) { * close browser and clean up created directories */ async.parallel([ - function(done) { browser.end(done); }, + function(done) { + browser.end() + .then(done.bind(null, null)) + .catch(done); + }, function(done) { fs.remove(failedComparisonsRootDefault,done); }, function(done) { fs.remove(screenshotRootDefault,done); }, function(done) { fs.remove(failedComparisonsRootCustom,done); }, From f4f0c5d6702eb97678b49ddccc4bfbd740061ac0 Mon Sep 17 00:00:00 2001 From: Benaka Moorthi Date: Mon, 30 May 2016 15:49:31 -0700 Subject: [PATCH 7/7] Get parts of instantiation spec to pass by changing before() hook to return a promise & checking properties in plugin.options instead of plugin. --- test/spec/instantiation.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/test/spec/instantiation.js b/test/spec/instantiation.js index 9302df2..be13c35 100644 --- a/test/spec/instantiation.js +++ b/test/spec/instantiation.js @@ -2,8 +2,8 @@ describe('WebdriverCSS plugin as WebdriverIO enhancement', function() { - before(function(done) { - this.browser = WebdriverIO.remote(capabilities).init(done); + before(function() { + return this.browser = WebdriverIO.remote(capabilities).init(); }); it('should not exist as command in WebdriverIO instance without initialization', function() { @@ -32,9 +32,9 @@ describe('WebdriverCSS plugin as WebdriverIO enhancement', function() { it('should contain some default values', function() { var plugin = WebdriverCSS.init(this.browser); - expect(plugin).to.have.property('screenshotRoot').to.equal('webdrivercss'); - expect(plugin).to.have.property('failedComparisonsRoot').to.equal('webdrivercss/diff'); - expect(plugin).to.have.property('misMatchTolerance').to.equal(0.05); + expect(plugin.options).to.have.property('screenshotRoot').to.equal('webdrivercss'); + expect(plugin.options).to.have.property('failedComparisonsRoot').to.equal('webdrivercss/diff'); + expect(plugin.options).to.have.property('misMatchTolerance').to.equal(0.05); }); @@ -45,9 +45,9 @@ describe('WebdriverCSS plugin as WebdriverIO enhancement', function() { misMatchTolerance: 50 }); - expect(plugin).to.have.property('screenshotRoot').to.equal('__screenshotRoot__'); - expect(plugin).to.have.property('failedComparisonsRoot').to.equal('__failedComparisonsRoot__'); - expect(plugin).to.have.property('misMatchTolerance').to.equal(50); + expect(plugin.options).to.have.property('screenshotRoot').to.equal('__screenshotRoot__'); + expect(plugin.options).to.have.property('failedComparisonsRoot').to.equal('__failedComparisonsRoot__'); + expect(plugin.options).to.have.property('misMatchTolerance').to.equal(50); }); it('should have a created "screenshotRoot" folder after initialization', function(done) {